问题
All,
I'm running into trouble deploying an ASP.NET 4.0 web page. The error is
System.InvalidProgramException: Common Language Runtime detected an invalid program
The error occurs on IIS7 on a 64 bit Windows Server box. The same page works on IIS7 on my development box (32bit Windows 7) and in the Visual Studio Development Environment. I'm not aware of any differences in the IIS7 configuration.
I've used PEVerify to validate the dll's in the application's bin directory.
I can reproduce the problem by using an Entity Framework query to populate a DataGrid.DataSource. It is not a particularly heavy query.
Any ideas on what could be causing this? My next step is to try and simply the queries used.
Thanks for any help.
回答1:
This looks like it's due to a primary key of type decimal(1,0).
回答2:
I think it could be a number of issues. Depending on your Entity Framework model, and how big/complex it is, you might be running into a limit of the JIT compiler. This applies to 2.0, so it might apply to 4.0 as well.
Assuming you don't have any huge methods, did you compile your assembly for Any CPU? If you specified a processor, then a mismatch between 32/64 bits will cause issues. Try rerunning with with Any CPU.
Let me know if that works.
Erick
回答3:
I got the same error on a line of code that was bug-free for months. Luckly, I was able to revert my changes to a working state and retrace my steps. It turns out that it was a line of code within the same Task.Run()
enclosure that was causing the error. What's scary is that there was nothing wrong with the code: var test = user.objectId.HasValue;
but once I remove this line, the error went away.
public virtual Task<IList<string>> GetRolesAsync(TUser user) {
if (user == null)
throw new ArgumentNullException("user");
return Task.Run(() => {
var test = user.objectId.HasValue;
var userRolesQuery = objectManager.buildQueryByFilter<List<security.UserRole>>("user = '{0}'", user.objectId);
objectManager.buildSubquery<TRole>("role", userRolesQuery);
var userRoles = objectManager.openByQuery<List<security.UserRole>>(userRolesQuery);
return (IList<string>)userRoles.Select(userRole => userRole.role.name).ToList();
});
}
来源:https://stackoverflow.com/questions/4109179/invalidprogramexception-common-language-runtime-detected-an-invalid-program