c# - The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception -
i trying use windows azure caching store sessions in mvc4 application. build application following steps link when try make object of datacache using below code line.
datacache cache = new datacache("default"); errors occurs:
microsoft.windowsazure.serviceruntime.dll not found or version mismatched, updated windows azure emulator version 2.0.0 , install windowsazure.caching package version 2.0.0.0 using nuget package installer. error changes "the type initializer 'microsoft.windowsazure.serviceruntime.roleenvironment' threw exception."
i using windows 8 vs2012 , windows azure emulator version 2.0.0.
i grateful if can me on this.
innerexception message: type initializer 'microsoft.windowsazure.serviceruntime.roleenvironment' threw exception. source: microsoft.windowsazure.serviceruntime stack trace: @ microsoft.windowsazure.serviceruntime.roleenvironment.get_isavailable() @ microsoft.applicationserver.caching.azureclienthelper.roleutility.isazureenvironmentavailable() stack trace: @ system.runtimemethodhandle.invokemethod(object target, object[] arguments, signature sig, boolean constructor) @ system.reflection.runtimemethodinfo.unsafeinvokeinternal(object obj, object[] parameters, object[] arguments) @ system.reflection.runtimemethodinfo.invoke(object obj, bindingflags invokeattr, binder binder, object[] parameters, cultureinfo culture) @ system.reflection.methodbase.invoke(object obj, object[] parameters) @ microsoft.applicationserver.caching.datacachefactoryconfiguration.initialize(string clientname) @ microsoft.applicationserver.caching.datacachefactoryconfiguration..ctor() @ microsoft.applicationserver.caching.datacachefactory..ctor() @ microsoft.applicationserver.caching.datacachefactory.initializeorfetchsingletonfactoryinstance(string clientconfigurationname) @ microsoft.applicationserver.caching.datacache..ctor(string cachename, string clientconfigurationname) @ microsoft.applicationserver.caching.datacache..ctor(string cachename) @ mvcwebrole.controllers.homecontroller.index() in d:\pankaj\azure.test\caching.sample\mvcwebrole\controllers\homecontroller.cs:line 15 @ lambda_method(closure , controllerbase , object[] ) @ system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) @ system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) @ system.web.mvc.controlleractioninvoker.<>c__displayclass15.<invokeactionmethodwithfilters>b__12() @ system.web.mvc.controlleractioninvoker.invokeactionmethodfilter(iactionfilter filter, actionexecutingcontext precontext, func`1 continuation)
i experienced when migrating from azure sdk 2.3 sdk 2.4.
i noticed migration automatically fixed references service runtime web , worker roles, i.e.
c:\program files\microsoft sdks\windows azure\.net sdk\v2.3\ref\microsoft.windowsazure.serviceruntime.dll changed to:
c:\program files\microsoft sdks\azure\.net sdk\v2.4\ref\microsoft.windowsazure.serviceruntime.dll however assemblies referenced web/worker roles referenced assembly didn't update had manually.
in addition had update web.config , app.config entries reference 2.4.0.0
<dependentassembly> <assemblyidentity name="microsoft.windowsazure.serviceruntime" publickeytoken="31bf3856ad364e35" culture="neutral" /> <bindingredirect oldversion="0.0.0.0-2.4.0.0" newversion="2.4.0.0" /> </dependentassembly>
Comments
Post a Comment