当我从visual studio 2010使用Web部署时,我收到以下错误。 Web部署任务失败。 ('Microsoft.Web.Deployment.DeploymentManager'的类型初始值设定项引发了异常。)
我突然开始收到此错误!我使用所有相同的设置多次发布我的网站,但突然间它开始给我这个错误。它可能是网站属性中的东西吗?我正在使用asp.net并拥有Windows 7并发布到Windows Server R2。请帮忙!
答案 0 :(得分:107)
好的,所以我遇到了这个问题,这些答案都没有对我有用。我把它归结为一行代码,即:
var deploymentOptions = new Microsoft.Web.Deployment.DeploymentBaseOptions();
如果您不手动将其传递给DeploymentManager,它将在内部实例化此对象。更有意思的是,这个代码对我来说运行正常,因为它是一个控制台应用程序的唯一一行,如果我把它放入单元测试中失败了(用vstest开始)。
以下是例外的全部内容:
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:\Source\Projects\SimpleTest.Test\UnitTest1.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:
在与微软拥有该组件的团队交谈后,我学到了一个简单的解决方案:
在以下路径下的注册表中查找指向问题程序集并删除它的键:
HKLM\Software\Microsoft\IIS Extensions\msdeploy\3\extensibility
HKLM\Software\Wow6432Node\Microsoft\IIS Extensions\msdeploy\3\extensibility
问题注册表项由SQL安装。
答案 1 :(得分:18)
我遇到了同样的问题,但安装SQL 2012并更改注册表并没有修复它。在我的开发机器上重新安装Web Deploy 3.5之后,事情就变得彻底了。
答案 2 :(得分:17)
只需卸载Microsoft dbsqlpackage提供程序即可。转到"程序和功能"。它已不再使用。
答案 3 :(得分:5)
对我来说,我重新启动了Visual Studio并重建了项目,我又能够再次发布(我没有看到这个答案,我觉得它很有用)。也许这是你在这个问题上尝试其他答案之前的第一步。
答案 4 :(得分:3)
我重新安装了Web Deployment 3.5,使其可以在Windows 8.1上运行。无法在注册表中找到这些文件。
答案 5 :(得分:2)
我能够通过重新安装SQL Server来解决此错误。我使用此文件名从MSDN重新安装了SQL 2012 Express。
仅下载940 MB。似乎已经修好了我上周所有的手动卸载工作。
en_sql_server_2012_express_edition_with_tools_with_sp1_x64.exe
我希望有所帮助。
答案 6 :(得分:1)
也许你需要在visual studio命令提示符下运行aspnet_regiis
。
答案 7 :(得分:1)
我似乎遇到了同样的问题,但只有在IIS Express上本地运行时(我的IIS 8实例运行此代码很好)。
当我在堆栈中跟踪异常时(三个内部异常)。看来实际例外情况如下:
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 Server\110\DAC\bin\Microsoft.Data.Tools.Utilities.dll
但实际上我有这个DLL。
同样奇怪的是,每当我尝试初始化新的DeploymentBaseOptions
时,这种情况才会发生。在我做任何事情之前(所以我没有进行任何SQL调用,甚至没有设置任何属性。
思想?
答案 8 :(得分:1)
我已经拥有SSMS 2014,这似乎不会导致在VS中发布出现任何问题。安装SQL Server 2014数据库引擎后,问题就出现了。
Victor提到的注册表项是空白的。重新安装VS2012解决了这个问题。
答案 9 :(得分:1)
进行"修复"我的SQL Server安装修复了我的问题。