不确定是否有其他人遇到这种情况,但是每当我在 Visual Studio 中调试我的计划任务时,我发现计划任务主机会加载父应用程序 DLL。我在输出窗口中看到它。我没有提及它,也没有使用其中的任何资源。
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: DefaultDomain): Loaded 'C:\windows\system32\mscorlib.ni.dll'.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.RuntimeHost.ni.dll'.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.ni.dll'.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Net.ni.dll'.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.ni.dll'.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Xml.ni.dll'.
// This is the actual app DLL!!
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{79787132-3A86-445F-BDD5-206D298D732F}\Install\MyWP8App.DLL'. Symbols loaded.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.ni.dll'.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.Interop.ni.dll'.
// This is the scheduled task DLL (as expected)
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{79787132-3A86-445F-BDD5-206D298D732F}\Install\MyWP8ScheduledTask.DLL'. Symbols loaded.
// This is the portable DLL for shared logic (as expected)
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{79787132-3A86-445F-BDD5-206D298D732F}\Install\MyWP8App.Shared.DLL'. Symbols loaded.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Threading.Tasks.ni.dll'.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Core.ni.dll'.
'HeadlessHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Runtime.Serialization.ni.dll'.
为什么会这样?当计划任务开始时,我的内存使用量已经是 4.4MB!