2010-09-15 10 views
2

需要任何幫助,想法找出這個問題。CLR檢測到一個無效的程序

我們正在研究一個應用程序,該應用程序使用ERPConnect調用SAP發佈一些數據。我們在我們的WCF服務的實體框架調用中遇到以下問題。我們正在使用.NET4.0,Win 2008 Server。

以下信息包括與事件:

exception in getting ****getrebateproposal**-****Common Language Runtime detected an invalid program.****** at System.Data.Entity.DynamicProxies.RebateProposal_E1004D9B0153012E0A7A09FC9B574872909349EC992253740AB3C066FC63CF4D.set_Id(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 CommercialTermsRepository.GetRebateProposalsAmountToPay(String rebateAgreement) in D:\Projects\TFS\CIT V2\DataModel\BusinessObjects\CommercialTermsRepository.cs:line 794 
     at SAPInterface.RebateProposalService.SetZv41Data(List`1 uploadRebates) in D:\Projects\TFS\CIT V2\Server\UserService\RebateProposalService.svc.cs:line 187 

回答

5
  1. 你嘗試的EXE/DLL運行PEVerify,看看是否有任何問題?
  2. 您是否嘗試在其上運行ngen來查看ngen是否失敗?
  3. 你可以發佈失敗的代碼或你的問題的一個小repro?

而且幾件事情,尋找:

  • 是在一個巨大的方法拉姆達? (也就是說,它是否結束了的值的值?) - 嘗試將其移出以便不是這種情況
  • 您是否使用在參數或輸出中具有COM對象的委託類型? (我以前遇到過這個問題)
+0

+1提及PEVerify,這是一款非常棒的il-verification程序。 – sisve 2010-09-15 13:55:37

1

這個問題有沒有解決?我遇到類似問題

InvalidProgramException: Common Language Runtime detected an invalid program

當動態代理嘗試爲小數類型的主鍵設置屬性時發生異常。這是我有同樣的錯誤情況。我能夠用一個簡單的Gridview和一個由一個表組成的數據庫重現問題。

我使用標準的POCO模板來生成上下文和代理。

解決方法是將主鍵更改爲int,如果這可能在您的環境中。它看起來像框架中的一個錯誤。

相關問題