大约两年前,我在.NET 2.0中编写了一个用于数据库访问的类库,并一直在.NET 2.0,3.0和3.5上使用它。.NET中的混合模式汇编4
在当前项目中我的工作(这是一个.NET 4.0的应用程序),使用旧的忠实类库试过,我得到了以下异常:
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:
有什么可能是错的,我该如何解决?
我重新编译.NET 4.0的类库,但仍然没有奏效。 难道是因为我在类库中引用了SQLite.NET 1.0.65.0? – 2010-07-05 11:33:28
重要提示:如果错误发生在“文件”错误列为“SGEN”,那么修复需要位于'sgen.exe'旁边的'sgen.exe.config'文件中。例如,对于VS 2015,创建'C:\ Program Files文件(x86)\ Microsoft SDKs \ Windows \ v10.0A \ bin \ NETFX 4.6 Tools \ sgen.exe.config'。资料来源:[SGEN混合模式程序集](https://support.microsoft.com/en-us/help/2572158/sgen-mixed-mode-assembly-is-built-against-version-v2-0-50727-of -the-ru)最小文件内容:' configuration>' –
ToolmakerSteve
2017-10-06 01:25:41