Web 部署任务失败.(“Microsoft.Web.Deployment.DeploymentManager"的类型初始值设定项引发异常.) [英] Web deployment task failed. (The type initializer for 'Microsoft.Web.Deployment.DeploymentManager' threw an exception.)

查看:42
本文介绍了Web 部署任务失败.(“Microsoft.Web.Deployment.DeploymentManager"的类型初始值设定项引发异常.)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从 Visual Studio 2010 使用 web 部署时,我收到以下错误.Web 部署任务失败.(Microsoft.Web.Deployment.DeploymentManager"的类型初始值设定项引发异常.)

I am getting the following error when I use web deploy from visual studio 2010. Web deployment task failed. (The type initializer for 'Microsoft.Web.Deployment.DeploymentManager' threw an exception.)

我突然开始收到这个错误!我使用所有相同的设置多次发布我的网站,但突然它开始给我这个错误.它可能是网站属性中的东西吗?我正在使用 asp.net 并拥有 Windows 7 并发布到 Windows Server R2.请帮忙!

I suddenly started getting this error! I published my website many many times with all the same settings, but suddenly it started to give me this error. Could it be something in the website properties? I am using asp.net and have Windows 7 and publishing to Windows Server R2. Please help!

推荐答案

好的,所以我遇到了这个问题,但这些答案都不适合我.我把它归结为一行代码,即:

Okay, so I hit this problem and none of these answers worked for me. I boiled it down to a single line of code, namely:

var deploymentOptions = new Microsoft.Web.Deployment.DeploymentBaseOptions();

如果您不手动将其传递给 DeploymentManager,它将在内部实例化此对象.更有趣的是,如果我将它放入单元测试(用 vstest 开始),这段代码作为控制台应用程序的唯一一行代码对我来说运行良好,但它会失败.

If you don't manually pass this to DeploymentManager it will internally instantiate this object. Even more interesting was that this code would run fine for me as the only line of a console app while it failed if I put it into a unit test (kicked off with vstest).

以下是异常的完整内容:

Here's the full body of the exception:

System.TypeInitializationException occurred
  HResult=-2146233036
  Message=The type initializer for 'Microsoft.Web.Deployment.DeploymentManager' threw an exception.
  Source=Microsoft.Web.Deployment
  TypeName=Microsoft.Web.Deployment.DeploymentManager
  StackTrace:
       at Microsoft.Web.Deployment.DeploymentManager.GetLinkExtensions()
       at Microsoft.Web.Deployment.DeploymentBaseOptions..ctor()
       at SimpleTest.Test.UnitTest1.TestMethod1() in f:SourceProjectsSimpleTest.TestUnitTest1.cs:line 12
  InnerException: System.TypeInitializationException
       HResult=-2146233036
       Message=The type initializer for 'Microsoft.Web.Deployment.BuiltInTypesCache' threw an exception.
       Source=Microsoft.Web.Deployment
       TypeName=Microsoft.Web.Deployment.BuiltInTypesCache
       StackTrace:
            at Microsoft.Web.Deployment.BuiltInTypesCache.get_Factories()
            at Microsoft.Web.Deployment.DeploymentProviderFactoryCollection.LoadFromRegistry()
            at Microsoft.Web.Deployment.DeploymentProviderFactoryCollection..ctor()
            at Microsoft.Web.Deployment.DeploymentManager.LoadDeploymentManagerSettings()
            at Microsoft.Web.Deployment.DeploymentManager..cctor()
       InnerException: Microsoft.Web.Deployment.DeploymentException
            HResult=-2146233088
            Message=The provider 'Microsoft.Data.Tools.Schema.MsDeploy.MsDeployProviderFactory' could not be loaded.
            Source=Microsoft.Web.Deployment
            StackTrace:
                 at Microsoft.Web.Deployment.DeploymentProviderFactory.Create(Type type)
                 at Microsoft.Web.Deployment.BuiltInTypesCache.InspectTypesForWebDeployAttributes(IEnumerable`1 types, String dllName)
                 at Microsoft.Web.Deployment.BuiltInTypesCache..cctor()
            InnerException: Microsoft.Web.Deployment.DeploymentException
                 HResult=-2146233088
                 Message=The type 'Microsoft.Data.Tools.Schema.MsDeploy.MsDeployProviderFactory' could not be loaded. The configuration settings may not be valid.
                 Source=Microsoft.Web.Deployment
                 StackTrace:
                      at Microsoft.Web.Deployment.ReflectionHelper.CreateInstance[T](Type type, Object[] constructorArguments)
                      at Microsoft.Web.Deployment.DeploymentProviderFactory.Create(Type type)
                 InnerException: System.TypeInitializationException
                      HResult=-2146233036
                      Message=The type initializer for 'Microsoft.Data.Tools.Schema.MsDeploy.MsDeployProviderBaseProviderFactory' threw an exception.
                      Source=mscorlib
                      TypeName=Microsoft.Data.Tools.Schema.MsDeploy.MsDeployProviderBaseProviderFactory
                      StackTrace:
                           at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
                           at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
                           at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
                           at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
                           at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
                           at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
                           at System.Activator.CreateInstance(Type type, Boolean nonPublic)
                           at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
                           at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
                           at System.Activator.CreateInstance(Type type, Object[] args)
                           at Microsoft.Web.Deployment.ReflectionHelper.CreateInstance[T](Type type, Object[] constructorArguments)
                      InnerException: System.IO.FileNotFoundException
                           HResult=-2147024894
                           Message=Could not load file or assembly 'Microsoft.Data.Tools.Schema.Sql, Version=10.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
                           Source=Microsoft.Data.Tools.Schema.DbSqlPackage
                           FileName=Microsoft.Data.Tools.Schema.Sql, Version=10.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
                           FusionLog=""
                           StackTrace:
                                at Microsoft.Data.Tools.Schema.MsDeploy.MsDeployProviderBaseProviderFactory..cctor()
                           InnerException:

在与拥有此组件的 Microsoft 团队交谈后,我了解到一个简单的解决方案:

After talking to the team in Microsoft that owns this component I learned a simple solution:

在注册表中的以下路径下查找指向问题程序集的键并将其删除:

Look for a key in the registry under the following paths that points the the problem assembly and delete it:

HKLMSoftwareMicrosoftIIS Extensionsmsdeploy3extensibility
HKLMSoftwareWow6432NodeMicrosoftIIS Extensionsmsdeploy3extensibility

(清理注册表后记得重启Visual Studio)

(After cleaning up the registry, remember to restart Visual Studio)

问题注册表项是由 SQL 安装的.

The problem registry key is installed by SQL.

这篇关于Web 部署任务失败.(“Microsoft.Web.Deployment.DeploymentManager"的类型初始值设定项引发异常.)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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