CLR 检测到无效程序

发布于 2024-09-19 08:33:01 字数 1360 浏览 5 评论 0原文

需要任何帮助、想法来解决这个问题。

我们正在开发一个应用程序,该应用程序可以调用 SAP 以使用 ERPConnect 发布一些数据。我们在 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

Need any help, ideas to figure out this issue.

We are working on an application that makes a call to SAP for posting some data using ERPConnect. We encounter the following issues in one of our Entity Framework call in our WCF service. We are using .NET4.0, Win 2008 Server.

The following information was included with the event:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

箹锭⒈辈孓 2024-09-26 08:33:02
  1. 您是否尝试在 exe/dll 上运行 PEVerify 以查看是否存在任何问题?
  2. 您是否尝试在其上运行 ngen 以查看 ngen 是否失败?
  3. 您可以发布失败的代码或问题的小重现吗?

还有一些需要注意的事情:

  • lambda 是否在一个巨大的方法中? (也就是说,它是否会超过很多值?) - 尝试将其移出,这样就不会出现这种情况
  • 您是否使用在参数或输出中具有 COM 对象的委托类型? (我过去也遇到过这样的问题)
  1. Did you try running PEVerify on the exe/dll to see if there are any issues?
  2. Did you try running ngen on it to see if ngen fails?
  3. Can you post the failing code or a small repro of your issue?

And a few things to look for:

  • Is the lambda in a gigantic method? (that is, is it closing over a lot of values?) - Try to move it out so that this is not the case
  • Are you using a delegate type that has a COM object in the params or output? (I've had issues with that in the past)
剩余の解释 2024-09-26 08:33:02

这件事得到解决了吗?我遇到了类似的问题

InvalidProgramException:公共语言运行时检测到无效程序

当动态代理尝试设置十进制类型的主键的属性时,会发生异常。这与我遇到的错误情况相同。我可以使用一个简单的 Gridview 和一个由一张表组成的数据库来重现该问题。

我使用标准 POCO 模板来生成上下文和代理。

如果您的环境可行,解决方法是将主键更改为 int。它看起来像是框架中的一个错误。

Did this ever get resolved? I'm running into a similar problem

InvalidProgramException: Common Language Runtime detected an invalid program.

The exception is occurring when the Dynamic Proxy is trying to set the property for a Primary Key that is of type decimal. This is the same error case I have. I am able to reproduce the problem with a simple Gridview and a database consisting of one table.

I am using the standard POCO templates to generate the Context and Proxies.

A workaround would be to change the primary key to an int if this is possible in your environment. It looks like a bug in the framework.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文