安装Vs 2012后,我想添加一个基于数据库的实体模型,但是T4模板无法构建。当我尝试调试时,会出现以下错误。
错误 1 - 装载程序集'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'时出现问题。抛出以下异常:System.BadImageFormatException:无法加载文件或程序集'file:///C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'或其某个依赖项。尝试加载格式不正确的程序。文件名:'file:///C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll' at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at Microsoft.VisualStudio.TextTemplating.TransformationRunner.AttemptAssemblyLoad(String assemblyName)
=== 预绑定状态信息 === LOG:用户 = MANNVIT\Ole LOG:Where-ref bind。位置= C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll LOG:Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/ LOG:初始PrivatePath = NULL 调用程序集:(未知)。=== LOG:此绑定在LoadFrom加载上下文中开始。 WRN:本机映像不会在LoadFrom上下文中探测。本机映像只会在默认加载上下文中,例如使用Assembly.Load()。LOG:未找到应用程序配置文件。LOG:使用主机配置文件:LOG:使用机器配置文件从C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config。LOG:尝试下载新的URL file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll。ERR:组件设置失败(hr = 0x8007000b)。探测终止。
警告2 编译转换:预定义类型'System.Runtime.CompilerServices.ExtensionAttribute'在全局别名中定义在多个程序集中;使用来自'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll'的定义 C:\Users\Ole\documents\visual studio 11\Projects\Cantina\Cantina\Models\navision.Context.tt
错误3 编译转换:名称空间'Microsoft'中不存在'CSharp' (是否缺少程序集引用?) c:\Users\Ole\AppData\Local\Temp\qiu0vq02.0.cs
错误4 编译转换:类型或命名空间名称'CSharpCodeProvider'找不到(是否缺少使用指令或程序集引用?) c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude 37 22
错误5 编译转换:名称空间'System.CodeDom.Compiler'中不存在'CompilerErrorCollection'(是否缺少程序集引用?) c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7
我认为问题在于它试图使用混合了32位和64位dll的组合。加载了64位mscorlib.dll和32位system.data.dll。(但我不确定)我的构建配置器平台是任何CPU。尝试在我的C#项目文件中添加x64,但没有帮助。我正在使用64位Win 7个人电脑。我还安装了VS 2010。我已经完成了以下工作:安装了VS 2012 Prof。RTM,卸载了VS 2012 Ultimate RC。之后,我注意到了这个错误。然后我尝试卸载所有.net框架和vs 2012 rtm。并重新安装vs 2012 rtm,但仍然会出现错误。有人能帮我解决一下吗?
错误 1 - 装载程序集'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'时出现问题。抛出以下异常:System.BadImageFormatException:无法加载文件或程序集'file:///C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'或其某个依赖项。尝试加载格式不正确的程序。文件名:'file:///C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll' at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at Microsoft.VisualStudio.TextTemplating.TransformationRunner.AttemptAssemblyLoad(String assemblyName)
=== 预绑定状态信息 === LOG:用户 = MANNVIT\Ole LOG:Where-ref bind。位置= C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll LOG:Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/ LOG:初始PrivatePath = NULL 调用程序集:(未知)。=== LOG:此绑定在LoadFrom加载上下文中开始。 WRN:本机映像不会在LoadFrom上下文中探测。本机映像只会在默认加载上下文中,例如使用Assembly.Load()。LOG:未找到应用程序配置文件。LOG:使用主机配置文件:LOG:使用机器配置文件从C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config。LOG:尝试下载新的URL file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll。ERR:组件设置失败(hr = 0x8007000b)。探测终止。
警告2 编译转换:预定义类型'System.Runtime.CompilerServices.ExtensionAttribute'在全局别名中定义在多个程序集中;使用来自'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll'的定义 C:\Users\Ole\documents\visual studio 11\Projects\Cantina\Cantina\Models\navision.Context.tt
错误3 编译转换:名称空间'Microsoft'中不存在'CSharp' (是否缺少程序集引用?) c:\Users\Ole\AppData\Local\Temp\qiu0vq02.0.cs
错误4 编译转换:类型或命名空间名称'CSharpCodeProvider'找不到(是否缺少使用指令或程序集引用?) c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude 37 22
错误5 编译转换:名称空间'System.CodeDom.Compiler'中不存在'CompilerErrorCollection'(是否缺少程序集引用?) c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7
我认为问题在于它试图使用混合了32位和64位dll的组合。加载了64位mscorlib.dll和32位system.data.dll。(但我不确定)我的构建配置器平台是任何CPU。尝试在我的C#项目文件中添加x64,但没有帮助。我正在使用64位Win 7个人电脑。我还安装了VS 2010。我已经完成了以下工作:安装了VS 2012 Prof。RTM,卸载了VS 2012 Ultimate RC。之后,我注意到了这个错误。然后我尝试卸载所有.net框架和vs 2012 rtm。并重新安装vs 2012 rtm,但仍然会出现错误。有人能帮我解决一下吗?