InvalidProgramException: Common Language Runtime detected an invalid program
Solution 1
This looks like it's due to a primary key of type decimal(1,0).
Solution 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
Related videos on Youtube
HatAndBeard
Updated on June 04, 2022Comments
-
HatAndBeard about 2 years
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.
-
HatAndBeard over 13 yearsThe data model isn't very large or complex (~25 entities). The CPU is compiled for Any CPU. My understanding from the 2.0 issue is that there was a hot fix to up the local variable limit to 4 million. I assume (hope) that wasn't overlooked when creating 4.0.
-
sirrocco over 13 yearsI had a composed primary key (created by the EF designer) on a view. One of the columns was decimal - BAM, the error :). Removing the decimal column as primary key fixed the issue. Thanks
-
dotariel over 13 years+ 1 - I ran into the same problem. I composed a model from a view, and the designer automatically assumed that a bunch of fields (including a decimal) were part of the entity key. After reading this post, I checked the properties on the model and manually removed the incorrect fields from the entity set key. This cleared the problem right up. Thanks!
-
Tedford over 13 years+1 XSaint32, it had not occurred to me to check if VS had automatically set extra columns as part of the entity key as I knew the key was a single column. Gotta love time sink gotchas like this.
-
HatAndBeard over 13 yearsThe bug was marked as fixed. Have you tried EF 4.1? connect.microsoft.com/VisualStudio/feedback/details/620031/…
-
JK. almost 13 years@hat how did you find which table in the EF model had an extra PK? I have several hundred tables - don't want to have to check each of them one by one