C# Entity Framework 4 Common Language Runtime detected an invalid program error?

后端 未结 4 1687
遥遥无期
遥遥无期 2021-01-12 04:36

How do you debug/fix a \"Common Language Runtime detected an invalid program\" error? What exactly does it mean anyway?

I have a C# MVC 2 web app that can deployed t

相关标签:
4条回答
  • 2021-01-12 05:25

    For me this happened when I added a view to my entity model. By default the designer sets all the columns Entity Key property to true. When I set it to false for all decimal/numeric columns the error goes away. Tas

    0 讨论(0)
  • 2021-01-12 05:25

    there is a major bug!!, i think it is while having decimal field column property in Entity framework,

    i have faced this nasty error msg, i compared getting data from 2 separate tables(same tables),one with an integer column ID and the other with decimal column ID,

    for the table with the integer column, no problem same code ran perfectly, for the table with a decimal column, this error message pop out i have made checks on sql server iis and the environment and i even wanted to format the pc, its very weird and the error msg is not clear.

    hope this approach helps any facing such an error in the future.

    0 讨论(0)
  • 2021-01-12 05:35

    I ran into this issue today when I deployed a web application implementing linq to entity 4 to our QA environment. The issue turned out to be an IIS setting on the Windows 2008 R2 server. Under Advanced Settings for the application pool, the setting for Enable 32-bit Applications was set to False. I set it to True and now my application works just as it did on the development server which happened to be a Windows 2003 server. I hope this helps.

    0 讨论(0)
  • 2021-01-12 05:40

    Have you tried to deploy the beta config on another machine? Are your apppools setup to be the same (i.e., classic vs integrated, same .net version)? Have you tried cleaning the solution and redeploying to a new location? Have you tried deploying beta build to release location? (be sure to delete all files before publishing; im curious if theres a leftover dynamically loaded dependency that might be causing problems)

    UPDATE:

    Excellent wrt more information. On line 3, you are defining the variable page while also using a previously defined variable named page. How does that compile? Try commenting out that code or at least try it without the skip.

    NOTE: I think that the Count() followed by the Take() might be executing the query twice.

    NOTE2: I've only used the EntityFramework v4 Database First development, but I don't remember programming directly against the ObjectSet. Usually it's your entity class (e.g., MyContext.Orders)... Maybe there is something going on with programming against that object and setting a Decimal value. Are there any properties on the model for that property that make it non-standard?

    0 讨论(0)
提交回复
热议问题