CSharp - 站点部署任务失败('Microsoft.Web.Deployment.DeploymentManager'的类型初始值设定项引发异常)

当我从Visual Studio 2010使用web deploy时,得到以下错误。Web deployment task failed. (The type initializer for'Microsoft.Web.Deployment.DeploymentManager'threw an exception. )

我多次用相同的设置发布了网站,但突然开始给我这个错误,请帮助!

时间:


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

如果不手动将此传递给DeploymentManager,它在内部实例化此对象。

以下是异常的完整主体:


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:

在注册表中查找指向问题程序集的以下路径下的项,并删除它:


HKLMSoftwareMicrosoftIIS Extensionsmsdeploy3extensibility
HKLMSoftwareWow6432NodeMicrosoftIIS Extensionsmsdeploy3extensibility

我有同样的问题,但是安装 SQL 2012并更改注册表没有解决问题。 在我的开发机器上重新安装站点部署 3.5后,已经被拉直。

我重新启动Visual Studio,并重建项目,能够再次发布

也许你需要在aspnet_regiis命令提示符下运行Visual Studio。

实际异常如下所示:


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.":"Microsoft.Data.Tools.Schema.Sql, Version=10.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

奇怪的是这个DLL驻留在@C:Program Files (x86)Microsoft SQL Server110DACbinMicrosoft.Data.Tools.Utilities.dll这里有这个DLL。

想法?

我可以通过重新安装SQL Server来解决这个错误,我用这个文件名从MSDN重新安装了SQL 2012 Express。

en_sql_server_2012_express_edition_with_tools_with_sp1_x64.exe

希望能帮助你。

Victor引用的注册表项为空,重新安装VS2012修复了问题。

我重新安装了Web Deployment 3.5,使它在Windows 8.1上工作,在注册表中找不到文件。

...