2012-07-10 87 views
1

我在VS 2010中构建了一个支持VSTO的.xlt模板项目,其目标是.NET 4.0。我可以在大多数64位Windows 7/32位Office 2010系统上安装它,但是在安装.xlt并在一台32位Windows 7/32位Office 2010计算机上打开时会出现下面的错误。如何在Excel 2010中强制执行CLR版本

从它的外观来看,Excel正在加载.NET 2.0的一些合并。在打开.xlt之前,我已确保禁用所有其他加载项。我如何强制Excel使用.NET 4.0 CLR。为什么它加载这些旧的程序集?

************** Exception Text ************** 
Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created. ---> System.BadImageFormatException: Could not load file or assembly 'BatchUploadTemplate, Version=1.0.4024.22371, Culture=neutral, PublicKeyToken=f0ddd6d55be31a41' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. 
File name: 'BatchUploadTemplate, Version=1.0.4024.22371, Culture=neutral, PublicKeyToken=f0ddd6d55be31a41' 
    at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) 
    at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) 
    at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 
    at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 
    at System.Reflection.Assembly.Load(String assemblyString) 
    at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.DomainInitializer.ActivatePipeline(String addInAssembly, String addInClass, String[] pipelineInfo) 
    at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.DomainInitializer.StartAddIn(IntPtr hostServiceProvider, String[] pipeline, String assemblyName, String[] entryPoints) 
    at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.DomainInitializer.StartAddIn(IntPtr hostServiceProvider, String[] pipeline, String assemblyName, String[] entryPoints) 
    at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.LoadMafPipeline(AppDomain newDomain, IntPtr hostServiceProvider, String fullAssemblyName, String[] entryPoints, OfficeApp officeApplication, OfficeVersion officeVersion, IntPtr& executor) 
    at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.CreateCustomizationDomainInternal(String solutionLocation, String manifestName, String documentName, Boolean showUIDuringDeployment, IntPtr hostServiceProvider, Boolean useFastPath, IntPtr& executor) 

WRN: Assembly binding logging is turned OFF. 
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. 
Note: There is some performance penalty associated with assembly bind failure logging. 
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. 

    --- End of inner exception stack trace --- 


************** Loaded Assemblies ************** 
mscorlib 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400) 
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll 
---------------------------------------- 
Microsoft.VisualStudio.Tools.Office.Runtime.v10.0 
    Assembly Version: 10.0.0.0 
    Win32 Version: 10.0.31007.0 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Office.Runtime.v10.0/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Office.Runtime.v10.0.dll 
---------------------------------------- 
System 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400) 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll 
---------------------------------------- 
System.Core 
    Assembly Version: 3.5.0.0 
    Win32 Version: 3.5.30729.5420 built by: Win7SP1 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll 
---------------------------------------- 
Microsoft.VisualStudio.Tools.Applications.Hosting.v10.0 
    Assembly Version: 10.0.0.0 
    Win32 Version: 10.0.31007.0 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Hosting.v10.0/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Hosting.v10.0.dll 
---------------------------------------- 
System.AddIn 
    Assembly Version: 3.5.0.0 
    Win32 Version: 3.5.30729.5446 built by: Win7SP1GDR 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.AddIn/3.5.0.0__b77a5c561934e089/System.AddIn.dll 
---------------------------------------- 
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0 
    Assembly Version: 10.0.0.0 
    Win32 Version: 10.0.31007.0 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 
---------------------------------------- 
Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0 
    Assembly Version: 9.0.0.0 
    Win32 Version: 9.0.30729.4130 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0/9.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll 
---------------------------------------- 
Microsoft.VisualStudio.Tools.Applications.Runtime.v10.0 
    Assembly Version: 10.0.0.0 
    Win32 Version: 10.0.31007.0 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime.v10.0/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.v10.0.dll 
---------------------------------------- 
System.Windows.Forms 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.5460 (Win7SP1GDR.050727-5400) 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll 
---------------------------------------- 
System.Drawing 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.5462 (Win7SP1GDR.050727-5400) 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll 
---------------------------------------- 
System.Deployment 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400) 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Deployment/2.0.0.0__b03f5f7f11d50a3a/System.Deployment.dll 
---------------------------------------- 
System.Configuration 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400) 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll 
---------------------------------------- 
System.Xml 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400) 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll 
---------------------------------------- 
System.Security 
    Assembly Version: 2.0.0.0 
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400) 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Security/2.0.0.0__b03f5f7f11d50a3a/System.Security.dll 
---------------------------------------- 
System.Xml.Linq 
    Assembly Version: 3.5.0.0 
    Win32 Version: 3.5.30729.5420 built by: Win7SP1 
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml.Linq/3.5.0.0__b77a5c561934e089/System.Xml.Linq.dll 
---------------------------------------- 
+0

没有Excel.exe.config文件,CLR版本由任何插件有幸首先加载的确定。 – 2012-07-10 23:58:35

+0

Excel.exe.config是一个有趣的想法。我在本地尝试了它,将CLR版本设置为.NET 2.0。奇怪的是,我的.NET 4.0定位.xlt仍然有效。我确实在加载.xlt时没有其他“活动”插件,但我不知道“活动”是否与“加载”相同 – AndreiM 2012-07-11 12:49:38

+0

不要在“本地”尝试它,在包含Excel.exe的目录中。 – 2012-07-11 13:05:35

回答

0

在我们结束了重新映像机器有问题。该模板项目在新注册表和新安装的Office 2010上安装时没有问题。

0

尝试在你的的app.config添加此,也请检查您是否.NET 4的完整的框架安装的机器

<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 
+0

感谢您的建议。正如你在app.config中描述的那样,我已经逐字配置了这个设置。不幸的是,问题依然存在于有问题的机器上。 – AndreiM 2012-07-11 12:40:49

+0

什么是该机器上安装的vsto运行时? – 2012-07-15 06:31:10

+0

我已经确保安装4.0。但是,至少还安装了一个旧版本。 – AndreiM 2012-07-15 22:59:51