大佬教程收集整理的这篇文章主要介绍了.Net 5 中的 ObjectDataProvider 抛出 System.BadImageFormatException,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试在 ObjectDataProvIDer
网络应用程序中使用 .Net-5
。因此我需要使用 System.windows.Data
,它可以与 PresentationFramework.dll
一起使用。我将程序集包含在 NuGet (<packagereference Include="PresentationFramework" Version="4.6.0" />
) 中。当我构建我的应用程序时,我已经收到以下警告:
warning NU1701: Package 'PresentationFramework 4.6.0' was restored using '.NETFramework,Version=v4.6.1,.NETFramework,Version=v4.6.2,Version=v4.7,Version=v4.7.1,Version=v4.7.2,Version=v4.8' instead of the project target framework 'net5.0'. This package may not be fully compatible with your project.
然后,当我尝试使用 ObjectDataProvIDer
创建一个 ObjectDataProvIDer myODP = new ObjectDataProvIDer();
对象时,我的应用程序崩溃了:
System.badImageFormatException: Could not load file or assembly 'PresentationFramework,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35'. Reference assemblIEs should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)
file name: 'PresentationFramework,PublicKeyToken=31bf3856ad364e35' ---> System.badImageFormatException: CAnnot load a reference assembly for execution.
如果感兴趣,我正在 x64 系统上的 linux docker 容器 (@H_282_3@mcr.microsoft.com/dotnet/sdk:5.0-focal) 中运行我的应用程序。
从我的 Google 搜索中,我已经尝试删除 bin
文件夹并重新构建,但没有成功。
其他答案似乎表明 System.badImageFormatException
表示引用了 x86 程序集,而我正在为 x64 构建。除了来自 NuGet 的版本,我似乎找不到任何其他版本的 PresentationFramework.dll
。
还是 ObjectDataProvIDer
只是 deprecated?
我的问题是:如何解决此问题并使 ObjectDataProvIDer
在 .Net-5
中工作?
甚至可以在 PresentationFramework.dll
中使用 .Net-5
吗?
顺便说一句,我也尝试让它在 .Net-3.1
中工作,但也出现了同样的问题。
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的.Net 5 中的 ObjectDataProvider 抛出 System.BadImageFormatException全部内容,希望文章能够帮你解决.Net 5 中的 ObjectDataProvider 抛出 System.BadImageFormatException所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。