ASP.NET MVC 应用程序中的“错误的二进制签名" [英] “Bad binary signature” in ASP.NET MVC application

查看:21
本文介绍了ASP.NET MVC 应用程序中的“错误的二进制签名"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里报告了同样的问题:"Bad二进制签名"在 ASP.NET MVC 应用程序中

I'm experiencing the same issue reported here: "Bad binary signature" in ASP.NET MVC application

ASP.Net MVC 站点在本地机器上运行良好,但是当使用 aspnet_compiler、aspnet_merge 和 msdeploy 的组合进行部署时,加载任何页面都将失败并显示以下错误:

The ASP.Net MVC site works fine on the local machine, but when deployed using a combination of aspnet_compiler, aspnet_merge, and msdeploy, loading any page will fail with the following error:

System.BadImageFormatException错误的二进制签名.(来自 HRESULT 的异常:0x80131192)

System.BadImageFormatException Bad binary signature. (Exception from HRESULT: 0x80131192)

链接问题中接受的解决方案表明该问题是由使用错误版本的 aspnet_merge 引起的,我已经验证从部署中删除 aspnet_merge 步骤可以解决该问题.

The accepted solution in the linked question suggests that the issue is caused by using the wrong version of aspnet_merge, and I have verified that removing the aspnet_merge step from the deployment solves the issue.

我的问题是使用正确的 aspnet_merge 版本似乎无法解决问题.

My problem is that using the correct aspnet_merge version doesn't appear to resolve the issue.

Web 应用程序面向 .Net 4.0 64 位.使用的aspnet_merge路径为:C:Program Files (x86)Microsoft SDKsWindowsv7.0AinNETFX 4.0 Toolsaspnet_merge.exe"

The web application is targeting .Net 4.0 64-bit. The aspnet_merge path used is: "C:Program Files (x86)Microsoft SDKsWindowsv7.0AinNETFX 4.0 Toolsaspnet_merge.exe"

本地开发是:

  • VS2010 SP1
  • 卡西尼号
  • x64
  • 安装了 VS11 Beta 和 .Net 4.5

构建路径是:

  • C:WindowsMicrosoft.NETFrameworkv4.0.30319
  • C:Program Files (x86)IISMicrosoft Web Deploy V2

推荐答案

我在 VS2010 (.NET 4.0) 中使用 Web 部署项目预编译 ASP.NET 网站项目时也遇到过类似问题.

I've also experienced a similar issue using a Web Deployment Project to pre-compile an ASP.NET Web Site Project in VS2010 (.NET 4.0).

一切正常,直到我安装了 VS2012(安装了 .NET 4.5 - 我认为这是相关的)它开始给我:

Everything worked fine until I installed VS2012 (which installs .NET 4.5 - I presume that is related) which started giving me:

System.BadImageFormatException: 错误的二进制签名.(来自 HRESULT 的异常:0x80131192)

经过一些调试和隔离测试用例后,我将问题追溯到在 .NET 4.0 网站和另一个 .NET 3.5 项目之间传递的 lambda.

After some debugging and isolated test cases I tracked the issue down to a lambda being passed between the .NET 4.0 web site and another .NET 3.5 project.

3.5 项目中定义的方法有这样的签名:

The method defined in the 3.5 project had a signature like this:

public IEnumberable<T> ExecuteAsEnumerable(Func<IDataReader, T> func)
{
  //..
}

在 4.0 网站中使用的属性 getter 导致在通过 aspnet_merge 合并时出错:

which was being used in the 4.0 website in a property getter resulting in the error when merged via aspnet_merge:

public IList<MyObject> MyListOfItems
{
  get
  { 
    return _myListOfItems ?? (_myListOfItems = new SomeQueryBuilder()
      //.build statement
      .ExecuteAsEnumerable(reader => new MyObject(reader))
      .ToArray());
  }
}

在我的测试案例中,我在 4.0 网站中重新创建了 ExecuteAsEnumerable 作为一个不同的命名扩展方法,并进行了预编译,它工作正常.检查项目的Target .NET Framework"并意识到它是3.5(我之前没有意识到)后,我将所有内容切换到4.0,并且一切正常.

In my test case I recreated ExecuteAsEnumerable as an different named extension method inside the 4.0 web site, pre-compiled, and it worked. After checking the "Target .NET Framework" of the project and realising it was 3.5 (I hadn't realised before), I switched everything to 4.0, and everything worked again.

.NET 4.5 更新(这是 4.0 之上的就地升级)中的某些内容显然发生了变化.在我的情况下,我可以重新编译有问题的项目 - 我不确定每个人都会有这种奢侈(这是正确的词吗?).

Something obviously changed in the .NET 4.5 update (which was an in place upgrade over 4.0). In my case I could recompile the project in question - I'm not sure everyone would have that luxury (is that the right word?).

希望有所帮助.

这篇关于ASP.NET MVC 应用程序中的“错误的二进制签名"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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