Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6160637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:20:17+00:00 2026-05-23T21:20:17+00:00

How do you debug/fix a Common Language Runtime detected an invalid program error? What

  • 0

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 to two websites that reside on the same IIS 7.5 webserver (x64). One is the live site (deployed using Release configuration), the second is the beta site (deployed using a new Beta configuration created just for this project).

The two websites are:

Default Website/my_app
Beta/my_app

On the beta site when selecting a paged list of purchase orders, it throws the “detected an invalid program” exception. The exact same code when run on the live site works perfectly. Why would it do this?

Edit: I installed Visual Studio on the server and found the actual line that was causing the problem and the stack trace:

var list = ObjectContext.ObjectSet.AsQueryable();
int totalRecords = list.Count();
var paged = list.Skip((page > 0 ? page - 1 : 0) * rows).Take(rows);

And this is the exception message with stack trace:

{System.InvalidProgramException: Common Language Runtime detected an invalid program.
   at System.Data.Entity.DynamicProxies.PurchaseOrderListVie_96479BFE9FA60F4C53137C56C1A1B2A11D90FF5AFFDC20383CC68E0A750792E3.set_Total(Decimal )
   at lambda_method(Closure , Shaper )
   at System.Data.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func`2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)
   at lambda_method(Closure , Shaper )
   at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
   at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at MyApp.Controllers.PurchaseOrderController.GetPurchaseOrderList(Int32 page, Int32 rows, String sidx, String sord) in C:\src\MyApp.2010\MyApp.UI\Controllers\PurchaseOrder\List.cs:line 11}

This new info shows exactly where the problem is, but not what the problem is. Hopefully someone who knows Entity framework very well can shed light on this:

System.Data.Entity.DynamicProxies.PurchaseOrderListVie_96479B_etc.set_Total(Decimal )

Is the line where the error occurs. Now I ran the query in sql management studio and the result was not null, and Total was not null either. So why did it have a problem calling set_Total()?

This is how the POCO defines the Total field (generated by a T4 template):

[Decimal] [Required] [DisplayName("Total")]
public virtual decimal Total
{
    get;set;
}

The main difference between the live and beta sites is the build configuration. But both of the configurations have every single project set to “Any CPU”.

All our development machines and servers are 64 bit. Could there be some difference between the IIS configuration of the websites that is causing this?

I’ve tried running PEVerify – but it just says “All Classes and Methods Verified.” How can PEVerify help with this type of problem?

BTW I can see that there are around 15 questions with “Common Language Runtime detected an invalid program problem” in the title. My question is not a duplicate and has several unique features that are different from the other questions that have a similar title (and only one of those 15 is about Entity Framework too – the rest are about Reflection or TFS)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:20:20+00:00Added an answer on May 23, 2026 at 9:20 pm

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my project i have enabled /clr (Common Language Runtime) support as well as
The debug screen says that django does not have write access to the db.
When I try to debug my C++ application I get the error The program
Debug HTTP is easy, you have all sort of tools to do it (like
Hitting debug will deploy the application to \program files\AppNamespace\AppName.exe and attach to it. However,
Receiving error: [debug] mod_headers.c(663): headers: ap_headers_output_filter() after I included this within the htaccess file:
I have a problem I just can't fix. I need to find if a
Can’t install application The application at /Users/myname/Documents/SDK/iPhoneApplications/x/build/Debug-iphoneos/x.app does not specify a CFBundleExecutable I don't
I have just switched over from the old png transparency fix using a htc
I have just branched our Common Business Layer projects from the main to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.