SGEN失败:尝试在VS2008中加载格式不正确的程序集 [英] SGEN failure: An attempt was made to load an assembly with an incorrect format in VS2008

查看:402
本文介绍了SGEN失败:尝试在VS2008中加载格式不正确的程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 我可以找到几个类似的问题,但是没有一个答案或确切的条件适用于我的情况。我有一个为x64构建的.NET 3.5项目。


  2. 我也有一个x64混合模式引用(也针对.NET 3.5)。在Visual Studio 2008中,我创建了一个Web引用,它使SGEN在发布版本中执行以创建助手DLL。


    如果我不要引用混合模式DLL ,这工作正常。如果我引用混合模式DLL,我得到这个错误(xxx只是一个占位符):

    lockquote

    SGEN:错误:用
    不正确的格式加载程序集:
    C:\ code\xxx\trunk\xxx\common\xxx\build\winx64\lib\xxx

    这是发出的命令:


    C:\ Program Files \ Microsoft SDKs \Windows\v6.0A\bin\sgen.exe
    / assembly:C:\ code\xxx\trunk\\ \\ xxxx \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll
    /reference:C:\Windows\Microsoft.NET\\ \\Framework\v2.0.50727\System.Configuration.Install.dll
    / reference:C:\ Pr ogram Files(x86)\ Reference
    Assemblies \Microsoft\Framework\v3.5\System.Core.dll
    /reference:C:\Windows\Microsoft.NET\\ \\Framework\v2.0.50727\System.Data.dll
    /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll
    / reference :C:\ Windows \ Microsoft \\\\ Framework \ v2.0.50727 \ System.EnterpriseServices.dll
    /reference:C:\Windows\assembly\GAC_MSIL\System.Management。 Automation \1.0.0.0__31bf3856ad364e35 \ System.Management.Automation.dll
    / reference:C:\程序文件(x86)\参考
    程序集\ Microsoft \ Framework \v3 .0 \ System.Runtime.Serialization.dll
    / reference:C:\程序文件(x86)\参考
    程序集\ Microsoft \ Framework \ v3.0 \ System.ServiceModel.dll
    / reference:C:\ Program Files(x86)\ Reference b $ b Assemblies \Micr osoft\Framework\v3.5\\\ System\\Web.Extensions.dll
    /reference:C:\Windows\Microsoft\\.NET\Framework\v2.0.50727\System.Web。 Services.dll
    /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll


    有什么想法?

    解决方案

    是否尝试过更改生成序列化程序集,如这个msdn文章?在我的情况下,这是票。



    只需转到您的项目属性,它在生成。




    I was able to find several similar questions asked and answered, but none of the answers or exact conditions applied to my situation.

    1. I have a .NET 3.5 project being built for x64.
    2. I also have an x64 mixed mode reference (also targeting .NET 3.5).
    3. In Visual Studio 2008, I created a Web Reference which causes SGEN to execute during a Release build to create the helper DLL.

    If I don't reference the mixed-mode DLL, this works fine. If I do reference the mixed mode DLL, I get this error (xxx is just a placeholder):

    SGEN : error : An attempt was made to load an assembly with an incorrect format: C:\code\xxx\trunk\xxx\common\xxx\build\winx64\lib\xxx.dll.

    This is the command being issued:

    C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\sgen.exe /assembly:C:\code\xxx\trunk\xxx\xxx\obj\x64\Release\xxx.dll /proxytypes /reference:..\common\xxx\build\winx64\lib\xxx.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.Install.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll /reference:C:\Windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll

    Any ideas?

    解决方案

    Have you tried changing Generate serialization assembly to Off, as suggested in this msdn post? In my case, that was the ticket.

    Just go to your Project properties, and it's under Build.

    这篇关于SGEN失败:尝试在VS2008中加载格式不正确的程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆