“Bad binary signature” in ASP.NET MVC application

后端 未结 6 1475
无人及你
无人及你 2020-12-19 00:59

We are getting the error above on some pages of an ASP.NET MVC application when it is deployed to a 64 bit Windows 2008 server box. It works fine on our development machines

6条回答
  •  执笔经年
    2020-12-19 01:33

    As this has been my most important source for the past three days of investigation I'll post my solution here.

    Similar to others reporting this problem, we have had a successful 32bit deployment environment running TeamCity but are moving to 64bit which is the only place this occurs. It also only appears on specific pages - not "intermittenly" or "randomly" as some are reporting.

    After methodically ruling out a whole host of things (predominantly aspnet_merge.exe version and the environment), and finding an MVC page where I could reproduce the problem, I had it down to being a code problem. Other places have also pointed towards lambda expressions being the cause which is somewhat true for us as well. The following code relates to code in views only.

    To get to the point, incorrect code or not, this will work on aspnet_merge.exe version 4.x running on 32bit:

    Model.MyEvents.Distinct(x => x.CategoryName).Many()
    

    Where as on aspnet_merge.exe version 4.x on 64bit it HAS to be written as:

    Model.MyEvents.Distinct((x, y) => x.CategoryName == y.CategoryName).Many()
    

    I am aware the hint is in the name IEquality*Comparer* which logically should take two arguments but the first version will compile and work in a 32bit environment.

    I just hope this post will help others in the same situation. I am then sure someone will be able to decipher this and grind it down to an 32-vs-64-bit IntPtr issue of some bizarre sort.

提交回复
热议问题