Monzie
Monzie

Reputation: 41

Getting DacServices error on one machine, not on another

We've got a process that includes creating a database on an SQL Server 11 and 10 database servers. We're using a dacpac to import this data in C# via DacServices. This is the code being used:

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

When we run this for initial testing from our local machines, it works as expected. However, when I toss this up on a server (it runs as part of a WCF service). I get the following error:

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)

Thanks in advance.

Upvotes: 1

Views: 593

Answers (1)

Monzie
Monzie

Reputation: 41

I finally got this figured out. The offending DLL was Microsoft.SqlServer.TransactSql.ScriptDom. Once I referenced that, everything worked as expected. Took a lot of digging to get to that spot though.

Upvotes: 1

Related Questions