標籤:
起步只有3個檔案:CoreRun.exe, coreclr.dll, mscorlib.dll, HelloWorld.exe
運行命令:CoreRun HelloWorld.exe
出錯:
Assert failure(PID 9672 [0x000025c8], Thread: 16280 [0x3f98]): 0! + 0x0 (0x00000000`00000000) File: e:\dev\github\dotnet\coreclr\src\utilcode\ccomprc.cpp, Line: 814 Image:E:\Dev\GitHub\DotNet\CoreClrHelloWorld\runtime_windows\CoreRun.exe**** MessageBox invoked, title ‘CoreRun.exe - Assert Failure (PID 9672, Thread 16280/3f98) ‘ **** 0! + 0x0 (0x00000000`00000000)e:\dev\github\dotnet\coreclr\src\utilcode\ccomprc.cpp, Line: 814
啟動Visual Studio進行調試,發現是因為少了mscorrc.debug.dll這個檔案。
this0x000007fdccd146b0 {coreclr.dll!CCompRC CCompRC::m_DefaultResourceDll} {m_Primary={m_LangId=0x000007fdccd146b0 L"en-US" ...} ...}CCompRC *m_Primary{m_LangId=0x000007fdccd146b0 L"en-US" m_hInst=0x0000000000000000 m_fMissing=1 }CCulturedHInstancem_pHash0x0000000000000000 CCulturedHInstance *m_nHashSize0intm_csMap0x000000a31a9cb933void *m_pResourceFile0x000007fdcc9cd200 L"mscorrc.debug.dll"const wchar_t *m_fpGetThreadUICultureId0x000007fdcbde5ac8 {coreclr.dll!GetThreadUICultureId(wchar_t[85] *)}int (wchar_t[85] *) *m_fpGetThreadUICultureNames0x000007fdcbde5d68 {coreclr.dll!GetThreadUICultureNames(StringArrayList *)}HRESULT (StringArrayList *) *
將mscorrc.debug.dll複製過來,繼續運行,出現下面的錯誤:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘System.Console, Version=999.999.999.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a‘ or one of its dependencies. The system cannot find the file specified. at Program.Main(String[] args)
需要System.Console程式集,將之從corefx編譯出來的程式集中複製過來。
繼續運行,又出錯,這次是需要System.Runtime.dll,從corefx的packages檔案夾(nuget packages)中複製過來(註:lib\net45子檔案夾)
接下來又需要System.IO.dll,也是從corefx的packages檔案夾中複製。
再接下來還需要從corefx的packages檔案夾中複製3個程式集:System.Threading.dll, System.IO.FileSystem.Primitives.dll, System.Diagnostics.Debug.dll。
這時,當前檔案夾一共有11個檔案:
coreclr.dllCoreRun.exeHelloWorld.exemscorlib.dllmscorrc.debug.dllSystem.Console.dllSystem.Diagnostics.Debug.dllSystem.IO.dllSystem.IO.FileSystem.Primitives.dllSystem.Runtime.dllSystem.Threading.dll
繼續運行,出現新的錯誤:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089‘ or one of its dependencies. The system cannot find the file specified. at System.ConsolePal.WindowsConsoleStream..ctor(IntPtr handle, FileAccess access) at System.ConsolePal.GetStandardFile(IntPtr handle, FileAccess access) at System.ConsolePal.OpenStandardOutput() at System.Console.OpenStandardOutput() at System.Console.<>c__DisplayClass3.<get_Out>b__4() at System.Console.EnsureInitialized[T](T& field, Func`1 initializer) at System.Console.get_Out() at System.Console.WriteLine(String value) at Program.DrawWindows() at Program.Main(String[] args)
System程式集就是mscorlib.dll,明明有這個檔案,卻說找不到。
後來換成corefx中packages\Microsoft.DotNet.CoreCLR.1.0.3-prerelease\lib\aspnetcore50中的mscrolib.dll,就不錯這個錯誤了。
但是運行CoreRun HelloWorld.exe卻無任何輸出,換成CoreRun -v HelloWorld.exe出現下面的錯誤:
HOSTLOG: Finding GetCLRRuntimeHost(...)HOSTLOG: Calling GetCLRRuntimeHost(...)HOSTLOG: Setting ICLRRuntimeHost2 startup flagsHOSTLOG: Starting ICLRRuntimeHost2HOSTLOG: Failed to start CoreCLR. ERRORCODE: 0x80004005/E_FAILHOSTLOG: Execution failed
一步一步就到這裡,暫時沒找到解決方案。
Windows上一步一步CoreRun