【问题标题】:Excel VSTO Add-in error - application domain could not be createdExcel VSTO 加载项错误 - 无法创建应用程序域
【发布时间】:2012-09-05 19:24:23
【问题描述】:

我有一个 Excel VSTO 加载项没有安装在我的一台用户计算机上。到目前为止,它在其他所有人的机器(8 台机器)上都可以正常安装,但是在这台特定的机器上,它会给出以下错误消息。

Customization could not be loaded because the application domain could not be created.


************** Exception Text **************
Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created. ---> System.TypeLoadException: Could not load type 'System.AddIn.Pipeline.QualificationDataAttribute' from assembly 'System.AddIn.Contract, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
   at System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount)
   at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
   at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Runtime.Remoting.Metadata.RemotingCachedData.GetSoapAttribute()
   at System.Runtime.Remoting.InternalRemotingServices.GetCachedSoapAttribute(Object reflectionObject)
   at System.Runtime.Remoting.SoapServices.GetXmlTypeForInteropType(Type type, String& xmlType, String& xmlTypeNamespace)
   at System.Runtime.Remoting.RemotingServices.DetermineDefaultQualifiedTypeName(Type type)
   at System.Runtime.Remoting.Metadata.RemotingTypeCachedData.get_QualifiedTypeName()
   at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props, ConstructorCallMessage& ctorCallMsg)
   at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(Type serverType)
   at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props, Boolean bNewObj)
   at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
   at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   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)
   --- 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
----------------------------------------

我不确定为什么会收到此错误。通过谷歌搜索,没有任何来自可靠来源的返回。我让用户验证已安装 .NET 3.5,以管理员身份运行它,但似乎没有任何帮助。

我有一个安装程序,它会自动将加载项从注册表挂接到 excel,但如果安装了 VSTO,则会出现相同的错误消息。

我不明白这条错误消息告诉我什么。谁能帮帮我?

【问题讨论】:

    标签: .net excel .net-3.5 vsto


    【解决方案1】:

    This post 声称遇到此异常时必须安装完整 .NET 框架(与客户端配置文件相反)。有几个人表示这解决了他们的问题。

    (理想情况下,您的 VSTO 应该只需要客户端配置文件框架。您是否在 VSTO 中做一些需要完整框架的事情,或者这是先决条件之一?)

    【讨论】:

    • 我无法使用我的项目类型制作项目 .NET 3.5 客户端配置文件。 “尝试重新定位项目已被取消。您选择的 .NET Framework 版本不受此项目类型的支持。”是因为我使用的是外部 COM 库吗?
    • 只是为了确认一下:您的项目已经针对完整框架并且您无法切换到客户端配置文件? (仅供参考,外部 COM 库可能不是问题。)
    • 正确,它目前是 .NET 3.5(不是客户端配置文件),我无法将其切换到客户端配置文件。
    • 那我觉得安装问题是用户的机器没有完整的.NET 3.5框架。您应该将其作为 VSTO 的先决条件。至于为什么您的项目无法切换到客户端配置文件,我怀疑您的项目引用了完整框架中的 DLL。
    • 我已经将 .NET 3.5 Framework 设置为先决条件。有趣的是,我什至没有在我的本地机器或我的 VM 上安装 .NET 3.5,但插件在两台机器上都可以工作。但是,我的机器上确实安装了 .NET 4.0。 3.5 的原因是因为我们的一些 VM 上还没有安装 .NET 3.5。
    【解决方案2】:

    好的 - 结果是用户机器出了点问题。如果用户卸载我的加载项并在他的机器上启用其他加载项,错误消息仍然出现。是时候对他的机器而不是我的插件进行故障排除了!

    作为其他人的注释,您可以通过将变量添加到环境变量 -> 系统变量中取消抑制错误消息来查看错误消息

    变量名称:VSTO_SUPPRESSDISPLAYALERTS

    变量值:0

    最终更新:

    原来用户拥有 Microsoft Office Professional Plus 2010,而 Visual Studio 无法为该版本的 Microsoft Office 生成插件。

    https://connect.microsoft.com/VisualStudio/feedback/details/687449/vsto-not-compatible-with-office-professional-plus-2010

    【讨论】:

      【解决方案3】:

      在 Windows 7 64 位上,我们遇到了类似的问题。一些引用错误是:

      Not loaded. A runtime error occurred during the loading of the COM Add-in.
      
      Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created.
      
      System.TypeLoadException: Could not load type 'System.AddIn.Pipeline.QualificationDataAttribute' from assembly 'System.AddIn.Contract, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
      

      此问题是由 Microsoft .NET Framework 3.5.1 中的损坏引起的,这是操作系统的一项功能。

      如何修复或重新安装 .NET Framework 3.5 http://www.adminarsenal.com/admin-arsenal-blog/how-to-repair-or-reinstall-net-framework-3-5/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多