Question

I have custome azure utility dll that has one method to read configuration values from ServiceConfiguration and also has fallback code to read from AppSettings from web.config in case RoleEntironment is not running . This DLLs works fine with Azure WCF project runnning on local and production cloud environment.

For some reason I am hosting this WCF service on Rackspace server on IIS.

On my local machine IIS, WCF service works fine but on Rackspace it crashes with following error:

The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception.

I have copied WindowsAzure.ServiceRuntime.dll, Diagnostics.dll and StorageClient.dll in bin on rackspace. Still it gives same error.

I have also tried copying <startup useLegacyV2RuntimeActivationPolicy="true"> to Web.config, still it does not work.

Any idea? Am I missing more cloud DLLs or some more configuration is needed?

Was it helpful?

Solution

I went through this pain recently. And it ended up being a mismatched version of the Microsoft.WindowsAzure.Diagnostics dll in the Azure project file causing the problem. If you have local working copy and a successful deploy from a previous version you can copy the deployed files from the Azure VM and compare them to your local set (it was the Worker Role that was failing for me). If not check the versions to make sure the version being referenced is included in the deploy with CopyLocal set to true.

OTHER TIPS

I have fixed this problem by adding useLegacyV2RuntimeActivationPolicy="true" in config file

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top