Error Calling DbContext Contructor
Posted: Mon 21 Oct 2013 18:38
We are using DevArt 7.2.104.0 against an Oracle 11g database. We are getting a "the type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception" error (error details at end of this post) calling the constructor of our DbContext Entity Model. We have not seen this error on our development workstations, but we see it on some of our Win 2008 production servers. I am hoping someone can point us in the right direction toward resolving this.
Our app.config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<connectionStrings>
<add name="PROKEntitiesConnectionString" connectionString="metadata=res://*/ProkModel.csdl|res://*/ProkModel.ssdl|res://*/ProkModel.msl;provider=Devart.Data.Oracle;provider connection string="User Id={DBUSERNAME};Password={DBPASSWORD};Server={DBNAME};Persist Security Info=True;Pooling=False"" providerName="System.Data.EntityClient" />
</connectionStrings>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.data>
<DbProviderFactories>
<remove invariant="Devart.Data.Oracle" />
<add name="dotConnect for Oracle" invariant="Devart.Data.Oracle"
description="Devart dotConnect for Oracle"
type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle,
Version=7.2.104.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</DbProviderFactories>
</system.data>
<system.serviceModel>
<services>
<service behaviorConfiguration="ProviderContracting.Service.ProviderContractingServiceBehavior" name="ProviderContracting.Service.ProviderContractingService">
<endpoint address="/ProviderContractingService" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IProviderContractingService" name="NetTcpBinding_IProviderContractingService" contract="ProviderContracting.Service.IProviderContractingService">
<identity>
<dns value="dc-twwebpwb01.thadmin.com"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://dc-twwebpwb01.thadmin.com:8624/ProkService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ProviderContracting.Service.ProviderContractingServiceBehavior">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceAuthorization impersonateCallerForAllOperations="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceThrottling
maxConcurrentCalls="200"
maxConcurrentSessions="200"
maxConcurrentInstances="200"
/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IProviderContractingService" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="100" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="100" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="00:20:00" enabled="false"/>
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
And the error we are seeing is this:
Exception type: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]
Source: mscorlib
Source Assembly: mscorlib.dll
Source Assembly Version: 4.0.0.0
Source Type: System.Runtime.Remoting.Proxies.RealProxy
Source Method: Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
Debug Build?: True
Message: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Service Model Action: http://schemas.microsoft.com/net/2005/1 ... cher/fault
Service Model Code: System.ServiceModel.FaultCode
Service Model Message: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Service Model Reason: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Service Model Detail Inner Exception Message: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Service Model Detail Inner Exception Type: System.TypeInitializationException
Service Model Detail Inner Exception Stack Trace: at System.Data.Entity.Internal.AppConfig.get_DefaultInstance()
at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
at PROKModel.PROKEntities..ctor() in d:\Build Agent\Builds\10\TW Provider\Test - Signature Service\Sources\ProviderContracting.Models\ProkModel.Designer.cs:line 41
at ProviderContracting.SignatureService.ProviderContractingSignatureService.GetDocumentForApprovalFileName(Int64 prokChangeSetId) in d:\Build Agent\Builds\10\TW Provider\Test - Signature Service\Sources\ProviderContracting.SignatureService\ProviderContractingSignatureService.cs:line 134
at ProviderContracting.SignatureService.ProviderContractingSignatureService.SendApproveRequestDocumentForApprovalWithReportBytes(String senderEmailAddress, String recipientEmailAddress, Int64 prokChangeSetId, Byte[] reportBytes, String& senderKey, String& fileName) in d:\Build Agent\Builds\10\TW Provider\Test - Signature Service\Sources\ProviderContracting.SignatureService\ProviderContractingSignatureService.cs:line 60
at SyncInvokeSendApproveRequestDocumentForApprovalWithReportBytes(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
Our app.config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<connectionStrings>
<add name="PROKEntitiesConnectionString" connectionString="metadata=res://*/ProkModel.csdl|res://*/ProkModel.ssdl|res://*/ProkModel.msl;provider=Devart.Data.Oracle;provider connection string="User Id={DBUSERNAME};Password={DBPASSWORD};Server={DBNAME};Persist Security Info=True;Pooling=False"" providerName="System.Data.EntityClient" />
</connectionStrings>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.data>
<DbProviderFactories>
<remove invariant="Devart.Data.Oracle" />
<add name="dotConnect for Oracle" invariant="Devart.Data.Oracle"
description="Devart dotConnect for Oracle"
type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle,
Version=7.2.104.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</DbProviderFactories>
</system.data>
<system.serviceModel>
<services>
<service behaviorConfiguration="ProviderContracting.Service.ProviderContractingServiceBehavior" name="ProviderContracting.Service.ProviderContractingService">
<endpoint address="/ProviderContractingService" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IProviderContractingService" name="NetTcpBinding_IProviderContractingService" contract="ProviderContracting.Service.IProviderContractingService">
<identity>
<dns value="dc-twwebpwb01.thadmin.com"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://dc-twwebpwb01.thadmin.com:8624/ProkService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ProviderContracting.Service.ProviderContractingServiceBehavior">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceAuthorization impersonateCallerForAllOperations="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceThrottling
maxConcurrentCalls="200"
maxConcurrentSessions="200"
maxConcurrentInstances="200"
/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IProviderContractingService" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="100" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="100" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="00:20:00" enabled="false"/>
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
And the error we are seeing is this:
Exception type: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]
Source: mscorlib
Source Assembly: mscorlib.dll
Source Assembly Version: 4.0.0.0
Source Type: System.Runtime.Remoting.Proxies.RealProxy
Source Method: Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
Debug Build?: True
Message: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Service Model Action: http://schemas.microsoft.com/net/2005/1 ... cher/fault
Service Model Code: System.ServiceModel.FaultCode
Service Model Message: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Service Model Reason: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Service Model Detail Inner Exception Message: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Service Model Detail Inner Exception Type: System.TypeInitializationException
Service Model Detail Inner Exception Stack Trace: at System.Data.Entity.Internal.AppConfig.get_DefaultInstance()
at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
at PROKModel.PROKEntities..ctor() in d:\Build Agent\Builds\10\TW Provider\Test - Signature Service\Sources\ProviderContracting.Models\ProkModel.Designer.cs:line 41
at ProviderContracting.SignatureService.ProviderContractingSignatureService.GetDocumentForApprovalFileName(Int64 prokChangeSetId) in d:\Build Agent\Builds\10\TW Provider\Test - Signature Service\Sources\ProviderContracting.SignatureService\ProviderContractingSignatureService.cs:line 134
at ProviderContracting.SignatureService.ProviderContractingSignatureService.SendApproveRequestDocumentForApprovalWithReportBytes(String senderEmailAddress, String recipientEmailAddress, Int64 prokChangeSetId, Byte[] reportBytes, String& senderKey, String& fileName) in d:\Build Agent\Builds\10\TW Provider\Test - Signature Service\Sources\ProviderContracting.SignatureService\ProviderContractingSignatureService.cs:line 60
at SyncInvokeSendApproveRequestDocumentForApprovalWithReportBytes(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)