1

我在VS2005 .Net 2中開發了一個大型解決方案。我們從TFS2010遷移到TFS2012(保持框架爲.Net v2)。在IDE中的所有做工精細,建造和安裝,但在執行程序時,得到以下問題簽名:從TFS2010遷移到TFS2012時System.Drawing V4的FileNotFoundException。異常代碼0xE0434F4D

Problem Event Name: CLR20r3 
Problem Signature 01: myProgram.exe 
Problem Signature 02: 1.0.0.5 
Problem Signature 03: 550f8264 
Problem Signature 04: mscorlib 
Problem Signature 05: 2.0.0.0 
Problem Signature 06: 53a12268 
Problem Signature 07: f15 
Problem Signature 08: 3 
Problem Signature 09: System.IO.FileNotFoundException 
OS Version:  6.1.7601.2.1.0.256.48 
Locale ID:   2057 

TFS2010構建服務器是Windows XP SP3的x86。

TFS2012構建服務器是Windows Server 2008 R2 x64。

我已經遷移框架到.NET 4和一切工作正常,但不幸的是有些客戶還禮淨2.

  1. 使用的WinDbg給我的以下內容:

    Problem Signature 04 gives us where the error originated, mscorlib. 
    Problem Signature 07 gives us the methodDef, which we can use to get the methodDesc 「702b8c10」 => 「System.RuntimeTypeHandle.GetTypeByName(String.String, Boolean, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)」 
    Problem Signature 08 gives us the Offset so when I do a dump of the IL, I get 「ldarg.0」 at offset 3. 
    

據我所見,System.RuntimeTypeHandle.GetTypeByName的參數1即字符串是0,因此是FileNotFound異常,但它不告訴我文件名。

  • 使用FusionLog給我的以下內容:
  • 它成功加載System.Drawing中V2但隨後也嘗試加載V4其失敗(我已經檢查了沒有的項目引用任何.Net v4程序集)。

    ** Assembly Binder Log Entry (30/03/2015 @ 14:45:05) *** 
    
    The operation failed. 
    Bind result: hr = 0x80070002. The system cannot find the file specified. 
    
    Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll 
    Running under executable C:\Program Files\Common Files\myProgram\myProgram.exe 
    --- A detailed error log follows. 
    
    === Pre-bind state information === 
    LOG: User = HOST1\Administrator 
    LOG: DisplayName = System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
    (Fully-specified) 
    LOG: Appbase = file:///C:/Program Files/Common Files/myProgram/ 
    LOG: Initial PrivatePath = NULL 
    LOG: Dynamic Base = NULL 
    LOG: Cache Base = NULL 
    LOG: AppName = myProgram.exe 
    Calling assembly : (Unknown). 
    === 
    LOG: This bind starts in default load context. 
    LOG: No application configuration file found. 
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config. 
    LOG: Post-policy reference: System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
    LOG: GAC Lookup was unsuccessful. 
    LOG: Attempting download of new URL file:///C:/Program Files/Common Files/myProgram/System.Drawing.DLL. 
    LOG: Attempting download of new URL file:///C:/Program Files/Common Files/myProgram/System.Drawing/System.Drawing.DLL. 
    LOG: Attempting download of new URL file:///C:/Program Files/Common Files/myProgram/System.Drawing.EXE. 
    LOG: Attempting download of new URL file:///C:/Program Files/Common Files/myProgram/System.Drawing/System.Drawing.EXE. 
    LOG: All probing URLs attempted and failed. 
    

    下面是從procmon中的摘錄:

    CreateFile C:\Windows\assembly\GAC_32\myProgram.resources\1.0.0.5_en_0a4a2ad97614f98d PATH NOT FOUND 
    CreateFile C:\Windows\assembly\GAC_MSIL\myProgram.resources\1.0.0.5_en_0a4a2ad97614f98d PATH NOT FOUND 
    CreateFile C:\Windows\assembly\GAC\myProgram.resources\1.0.0.5_en_0a4a2ad97614f98d PATH NOT FOUND 
    CreateFile C:\Program Files\Common Files\myProgram\en\myProgram.resources.dll PATH NOT FOUND 
    CreateFile C:\Program Files\Common Files\myProgram\en\myProgram.resources\myProgram.resources.dll PATH NOT FOUND 
    CreateFile C:\Program Files\Common Files\myProgram\en\myProgram.resources.exe PATH NOT FOUND 
    CreateFile C:\Program Files\Common Files\myProgram\en\myProgram.resources\myProgram.resources.exe PATH NOT FOUND 
    CreateFile C:\Windows\assembly\GAC_32\System.Drawing\4.0.0.0__b03f5f7f11d50a3a PATH NOT FOUND 
    CreateFile C:\Windows\assembly\GAC_MSIL\System.Drawing\4.0.0.0__b03f5f7f11d50a3a NAME NOT FOUND 
    CreateFile C:\Windows\assembly\GAC\System.Drawing\4.0.0.0__b03f5f7f11d50a3a PATH NOT FOUND 
    CreateFile C:\Program Files\Common Files\myProgram\System.Drawing.dll NAME NOT FOUND 
    CreateFile C:\Program Files\Common Files\myProgram\System.Drawing\System.Drawing.dll PATH NOT FOUND 
    CreateFile C:\Program Files\Common Files\myProgram\System.Drawing.exe NAME NOT FOUND 
    CreateFile C:\Program Files\Common Files\myProgram\System.Drawing\System.Drawing.exe PATH NOT FOUND 
    

    正如你可以看到它會嘗試加載myProgram.resources.dll和失敗,然後嘗試加載框架V4文件的,這讓我看看資源文件。

    1. mscorlib.resources.dll通過.Net和Silverlight語言包安裝。試圖安裝Silverlight作爲我們的TFS2010構建服務器有這個,但沒有奏效。

    2. [本文]:"Could not load file or assembly System.Drawing or one of its dependencies" error on .Net 2.0, VS2010 and Windows 8說System.Drawing錯誤是由於VS中的資源文件錯誤。 我已經嘗試了建議的解決方案:

    編輯圖像流的頂線:AAEAAAD ///// AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w TO AAEAAAD ///// AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w 沒有資源文件的在我的解決方案有圖像流中的錯誤頂行「j00LjAuMC4w」

    還檢查了4.0.0.0版本的所有.resx文件,但它們都是2.0.0。0

  • 這裏的崩潰贈送轉儲:
  • 轉儲摘要

    Dump File: WER6229.tmp.mdmp :  C:\Users\Administrator\AppData\Local\Temp\WER6229.tmp.mdmp 
    Last Write Time: 16/04/2015 10:46:17 
    Process Name: myProgram.exe : C:\Program Files (x86)\Common Files\myProgram\myProgram.exe 
    Process Architecture: x86 
    Exception Code: 0xE0434F4D 
    Exception Information: An exception came from the CLR 
    Heap Information: Not Present 
    
    System Information 
    ------------------ 
    OS Version: 6.1.7601 
    CLR Version(s): 2.0.50727.5485 
    
    Modules 
    ------- 
    Module Name Module Path Module Version 
    ----------- ----------- -------------- 
    myProgram.exe C:\Program Files (x86)\Common Files\myProgram\myProgram.exe 1.4.2015.12 
    ntdll.dll C:\Windows\SysWOW64\ntdll.dll 6.1.7601.18247 
    mscoree.dll C:\Windows\System32\mscoree.dll 4.0.40305.0 
    kernel32.dll C:\Windows\SysWOW64\kernel32.dll 6.1.7601.18409 
    KERNELBASE.dll C:\Windows\SysWOW64\KERNELBASE.dll 6.1.7601.18409 
    advapi32.dll C:\Windows\SysWOW64\advapi32.dll 6.1.7601.18247 
    msvcrt.dll C:\Windows\SysWOW64\msvcrt.dll 7.0.7601.17744 
    sechost.dll C:\Windows\SysWOW64\sechost.dll 6.1.7600.16385 
    rpcrt4.dll C:\Windows\SysWOW64\rpcrt4.dll 6.1.7601.18532 
    sspicli.dll C:\Windows\SysWOW64\sspicli.dll 6.1.7601.18719 
    CRYPTBASE.dll C:\Windows\SysWOW64\CRYPTBASE.dll 6.1.7600.16385 
    mscoreei.dll C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll 4.0.30319.18408 
    shlwapi.dll C:\Windows\SysWOW64\shlwapi.dll 6.1.7601.17514 
    gdi32.dll C:\Windows\SysWOW64\gdi32.dll 6.1.7601.18577 
    user32.dll C:\Windows\SysWOW64\user32.dll 6.1.7601.17514 
    lpk.dll C:\Windows\SysWOW64\lpk.dll 6.1.7601.18177 
    usp10.dll C:\Windows\SysWOW64\usp10.dll 1.626.7601.18454 
    imm32.dll C:\Windows\System32\imm32.dll 6.1.7601.17514 
    msctf.dll C:\Windows\SysWOW64\msctf.dll 6.1.7600.16385 
    mscorwks.dll C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll 2.0.50727.5485 
    msvcr80.dll C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6229_none_d089f796442de10e\msvcr80.dll 8.0.50727.6229 
    shell32.dll C:\Windows\SysWOW64\shell32.dll 6.1.7601.18429 
    ole32.dll C:\Windows\SysWOW64\ole32.dll 6.1.7601.17514 
    profapi.dll C:\Windows\SysWOW64\profapi.dll 6.1.7600.16385 
    mscorlib.ni.dll C:\Windows\assembly\NativeImages_v2.0.50727_32\mscorlib\38bf604432e1a30c954b2ee40d6a2d1c\mscorlib.ni.dll 2.0.50727.5485 
    mscorsec.dll C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorsec.dll 2.0.50727.5483 
    wintrust.dll C:\Windows\SysWOW64\wintrust.dll 6.1.7601.18205 
    crypt32.dll C:\Windows\SysWOW64\crypt32.dll 6.1.7601.18277 
    msasn1.dll C:\Windows\SysWOW64\msasn1.dll 6.1.7601.17514 
    comctl32.dll C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_ec80f00e8593ece5\comctl32.dll 5.82.7601.18201 
    cryptsp.dll C:\Windows\System32\cryptsp.dll 6.1.7600.16385 
    rsaenh.dll C:\Windows\System32\rsaenh.dll 6.1.7600.16385 
    imagehlp.dll C:\Windows\SysWOW64\imagehlp.dll 6.1.7601.18288 
    ncrypt.dll C:\Windows\System32\ncrypt.dll 6.1.7601.18714 
    bcrypt.dll C:\Windows\System32\bcrypt.dll 6.1.7600.16385 
    bcryptprimitives.dll C:\Windows\SysWOW64\bcryptprimitives.dll 6.1.7600.16385 
    userenv.dll C:\Windows\SysWOW64\userenv.dll 6.1.7601.17514 
    gpapi.dll C:\Windows\System32\gpapi.dll 6.1.7601.18711 
    cryptnet.dll C:\Windows\System32\cryptnet.dll 6.1.7601.18205 
    Wldap32.dll C:\Windows\SysWOW64\Wldap32.dll 6.1.7601.17514 
    SensApi.dll C:\Windows\System32\SensApi.dll 6.1.7600.16385 
    uxtheme.dll C:\Windows\System32\uxtheme.dll 6.1.7600.16385 
    mscorjit.dll C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll 2.0.50727.5467 
    myProgram.Engine.dll C:\Windows\assembly\GAC_MSIL\myProgram.Engine\1.0.0.5__0a4a2ad97614f98d\myProgram.Engine.dll 1.4.2015.12 
    System.ni.dll C:\Windows\assembly\NativeImages_v2.0.50727_32\System\908ba9e296e92b4e14bdc2437edac603\System.ni.dll 2.0.50727.5485 
    System.Drawing.ni.dll C:\Windows\assembly\NativeImages_v2.0.50727_32\System.Drawing\836e10dfd0811b303553216f5cb092ef\System.Drawing.ni.dll 2.0.50727.5483 
    System.Windows.Forms.ni.dll C:\Windows\assembly\NativeImages_v2.0.50727_32\System.Windows.Forms\1453d9e9a4989833ef3db4b22549ba1a\System.Windows.Forms.ni.dll 2.0.50727.5483 
    myProgram.Designer.dll C:\Windows\assembly\GAC_MSIL\myProgram.Designer\1.0.0.5__0a4a2ad97614f98d\myProgram.Designer.dll 1.4.2015.12 
    myProgram.UI.dll C:\Windows\assembly\GAC_MSIL\myProgram.UI\1.0.0.5__0a4a2ad97614f98d\myProgram.UI.dll 1.4.2015.12 
    DevComponents.DotNetBar.dll C:\Windows\assembly\GAC\DevComponents.DotNetBar\5.8.0.0__7eb7c3a35b91de04\DevComponents.DotNetBar.dll 5.8.0.0 
    version.dll C:\Windows\System32\version.dll 6.1.7600.16385 
    apphelp.dll C:\Windows\System32\apphelp.dll 6.1.7601.17514 
    

    迷你故障轉儲給我的異常代碼0xE0434F4D。

    • 試過[這個想法] [program name].exe has stopped working運行myProgram作爲管理員,但沒有幫助。
    • [此博客] http://blog.toxa.de/archives/38(也涉及.Net 2)給了我這個想法從SplashScreen中移除圖標。這會影響所引發的錯誤。而不是像上面描述的那樣得到1錯誤,而用continue選項得到3個錯誤。

    • 從生成日誌:

    我看到的MSBuild從框架V4使用

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo /noconsolelogger "F:\Builds\59\Platform\myProject_BugFixing_CI\BuildType\TFSBuild.proj" /m:1 /nr:False "@F:\Builds\59\Platform\myProject_BugFixing_CI\BuildType\TfsBuild.rsp" 
    
    • 嘗試過加入集ToolsVersion = 2.0和TargetFrameworkVersion = v2.0在每個項目文件和ToolsVersion =「2.0」在TFSBuild.proj。

    • 從命令行然框架V2的MSBuild:

      • 開關(次/ m的無:1/NR:假「@F:\構建\ 59 \平臺\ myProgram_BugFixing_CI \ BuildType \ TfsBuild.rsp 「)被認可。
      • 刪除這些之後,由於無法識別SolutionRoot,所以構建在TFSBuild.proj的第7行上失敗。
      • 如果我對此進行了硬編碼,則構建將在C:\ Program Files(x86)\ MSBuild \ Microsoft \ VisualStudio \ TeamBuild \ Microsoft.TeamFoundation.Build.targets 359行也引用SolutionRoot。它說在命名空間中有一個無效的子元素_SolutionRoot。
      • 這表明MSBuild v4是正確的版本,也必須由TFS2010構建服務器使用。

      • TFS Build.log揭示的構建中使用不同版本RESGEN:

    我替換爲TFS2010構建服務器的exe的TFS2012構建服務器RESGEN併成功地完成了構建,這沒有什麼區別。

    TFS2010 – Path of ResGen used: C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\ResGen.exe 
        This is v3.5.30729.4507 and dated 19/03/2010 
    
        TFS2012 – Path of ResGen used: C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\bin\Resgen.exe 
        This is v2.0.50727.42 and dated 23/09/2005 
    

    本帖] MSBuild cant find resgen.exe建議設置

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentVersion 
    

    到相同的值設置ProductionVersion在

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A 
    

    這是V8,但這並沒有工作。

    1. 在myProgram.exe(兩個版本)上使用IlSpy反編譯代碼顯示兩個樹結構,其中反編譯的.cs文件相同,但二進制.resource文件不同大小&內容)。

    特別二進制編輯表明,在mainform.resources的尾部是線(當然還有其他差別):

    System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d 
    
    在舊TFS2010 EXE

    ,VS

    System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 
    

    在新的TFS2012 exe中。 這意味着新版本使用.Net 4二進制序列化;舊的使用.Net 2二進制序列化。

    RESGEN的快速反編譯顯示這是一個非常簡單的程序:

    • 解析ARGS
    • 從.resx文件中讀取資源
    • 使用二進制資源的作家寫的輸出文件

    我懷疑這兩個版本非常相似,因爲應該沒有真正需要更改(兩者實際上都標記爲.net2/AnyCPU)。

    更有趣的是,使用的二進制串行器來自mscorlib程序,因此新的版本必須是儘管使用.net 4 mscorlib程序 (但生成日誌說,這是V2

    C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll 
    FusionName = mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
    

    )這RESGEN實際上是.Net 2二進制文件 - 這可以解釋爲什麼覆蓋上面第7點中嘗試的ResGen.exe版本沒有任何作用。

    回答

    0

    通過更改TFS2012構建服務器來解決: Windows Server 2008 R2 x64 => Windows 7 x86