2015-08-14 35 views
0

我們有一個過程,包括SQL Server的11和10臺數據庫服務器上創建數據庫。我們使用dacpac通過DacServices在C#中導入這些數據。這是使用的代碼:獲得DacServices錯誤一臺計算機上,而不是另一種

var dac = new DacServices(masterConnString); 
using (var bacPac = BacPackage.Load(templatePath)) 
{ 
    dac.ImportBacpac(bacPac, dealer.VSID.ToString(CultureInfo.InvariantCulture)); 
} 

當我們從我們的本地機器運行此初始測試時,它按預期工作。但是,當我在服務器上運行它時(它作爲WCF服務的一部分運行)。我收到以下錯誤:

The type initializer for 'Microsoft.SqlServer.Dac.DacServices' threw an exception.

Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at IWcfService.Method(String string, Int32 integer) at WcfServiceClient.Method(String string, Int32 integer)

在此先感謝。

+0

的聲音,我剛剛從閱讀您的問題,有一個'的Dll assembly'問題是何等的是,本地引用特定組件..是不是標誌着'CopyLocal = TRUE;也可能這是一個'GAC'檢查所有引用和確保它們在目標機器上相同 – MethodMan

回答

0

我終於明白了。有問題的DLL是Microsoft.SqlServer.TransactSql.ScriptDom。一旦我引用它,一切都按預期工作。花了很多時間去挖掘這個地方。

相關問題