我在C#上相当新,所以如果我误解了某些东西,请耐心等待。System.BadImageFormatException使用.NET 2.0
我有我的工作的相当老的应用程序,允许你导入的DLL做某些自动执行的任务。所有的老程序员都离开了几年,我不支持联系这个应用程序。我创建了一个DLL在Visual Studio 2013使用.NET 2.0框架,并试图导入它时,我收到此错误信息:
The format of the file 'MyDll.dll' is invalid. Type:System.BadImageFormatException
Source: mscorlib Stack Trace: at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Applications.frmApplications.loadFields()
at Applications.frmApplications.fillMenuItem()
at Applications.frmApplications.ugApplications_AfterSelectChange(Object sender, AfterSelectChangeEventArgs e)
at Infragistics.Win.UltraWinGrid.UltraGrid.OnAfterSelectChange(AfterSelectChangeEventArgs e)
at Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(GridEventIds id, EventArgs e)
at Infragistics.Win.UltraWinGrid.UltraGrid.SelectNewSelection(Type type, Selected selected)
at Infragistics.Win.UltraWinGrid.UltraGrid.InternalSelectItem(ISelectableItem item, Boolean clearExistingSelection, Boolean select)
at Infragistics.Win.UltraWinGrid.UltraGridRow.set_Selected(Boolean value)
at Applications.frmApplications.searchForApplication()
我在网上查找这个错误的基本consensious是我使用了错误的。 NET框架版本。我已经使用.NET Reflector来查看工作中使用的较老的dll的版本,并且它的版本为1.1.12.30886 。现在我的问题是有另一种方式绕过这个错误,或者只能导入.NET版本1.1?如果是的话,是否有任何方法可以将我的dll更改为1.1框架,因为我看到它过去的生命周期并且不再受支持,而且我也没有看到在Visual Studio中安装它的方法。
可能是一个64/32位的问题。 –
我也这么认为,但是我将它设置为任何cpu。只是为了笑笑,我试图切换到64/32,并给出了相同的错误。 – Superdoo
你确定这是目标框架的版本,而不是dll的?无论如何,.NET 1.1是非常古老的。从1.1到2.0的变化影响了IL和运行时本身。 –