在.NET 4.0混合模式总成 [英] Mixed mode assembly in .NET 4

查看:249
本文介绍了在.NET 4.0混合模式总成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.NET 2.0的一些2年前写了一个类库,数据库访问并一直在使用它一直在.NET 2.0,3.0和3.5。

I wrote a class library in .NET 2.0 for database access some 2 years ago and have been using it all along on .NET 2.0, 3.0 and 3.5.

在当前项目中我的工作(这是一个.NET 4.0的应用程序),尝试使用老友们类库,我得到了以下异常:

In the current project I'm working on (which is a .NET 4.0 application), tried using the old faithful class library and I got the following exception:


System.InvalidOperationException was unhandled
  Message=An error occurred creating the form. See Exception.InnerException for details.
    The error is: Mixed mode assembly is built against version 'v2.0.50727' of the runtime
    and cannot be loaded in the 4.0 runtime without additional configuration information.
    Source=SchoolManager
  StackTrace:
       at SchoolManager.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
       at SchoolManager.My.MyProject.MyForms.get_frmGeneric()
       at SchoolManager.My.MyApplication.OnCreateMainForm() in D:\Alex\Documents\Visual Studio 2008\Projects\School Manager\SchoolManager\My Project\Application.Designer.vb:line 35
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at SchoolManager.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.FileLoadException
       Message=Mixed mode assembly is built against version 'v2.0.50727' of 
           the runtime and cannot be loaded in the 4.0 runtime without additional
           configuration information.
       Source=Dinofage.Data.XpressData
       StackTrace:
            at Dinofage.Data.XpressData.ExecuteSelectInternal(String selectCommand)
            at Dinofage.Data.XpressData.ExecuteSelect(String selectCommand)
            at SchoolManager.Academics.GetNewAdmissionCode(String academicYear) in D:\Alex\Documents\Visual Studio 2008\Projects\School Manager\SchoolManager\Modules\Academics.vb:line 89
            at SchoolManager.StudentDetail..ctor() in D:\Alex\Documents\Visual Studio 2008\Projects\School Manager\SchoolManager\UserControls\StudentDetail.vb:line 20
            at SchoolManager.frmGeneric.InitializeComponent() in D:\Alex\Documents\Visual Studio 2008\Projects\School Manager\SchoolManager\frmGeneric.Designer.vb:line 25
            at SchoolManager.frmGeneric..ctor()
       InnerException: 


出了什么问题,如何解决呢?


What could be wrong and how do I fix it?

推荐答案

最好的很可能是重新编译类库.NET 4.0在Visual Studio 2010(即开放的项目,将其转换和改变目标框架。)

The best would probably be to recompile your class library for .NET 4.0 in Visual Studio 2010 (ie. opening up the project, converting it, and changing the target framework.)

如果你不能,或不愿,做到这一点,那么你可以尝试添加以下到您的app.config文件为您的.NET 4.0应用程序:

If you can't, or won't, do that, then you can try adding the following to your app.config file for your .NET 4.0 application:

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
</startup>

<?xml version ="1.0"?> 
<configuration> 
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
    </startup>
</configuration>

这篇关于在.NET 4.0混合模式总成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆