Der Typinitialisierer für 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' hat eine Ausnahme ausgelöst

Ich versuche, Windows Azure Caching zum Speichern von Sitzungen in einer MVC4-Anwendung zu verwenden. Ich erstelle eine Anwendung in den folgenden Schritten vonVerknüpfung aber wenn ich versuche, Objekt von DataCache unter Verwendung der folgenden Codezeile zu bilden.

DataCache cache = new DataCache("default");

Fehler treten auf:

Microsoft.WindowsAzure.ServiceRuntime.dll wurde nicht gefunden oder die Version stimmt nicht überein. Ich habe meine Windows Azure Emulator-Version auf 2.0.0 aktualisiert und das WindowsAzure.Caching-Paket Version 2.0.0.0 mithilfe des NuGet-Paketinstallationsprogramms installiert. Jetzt ändert sich der Fehler in "Der Typinitialisierer für 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' hat eine Ausnahme ausgelöst."

ich benutzeWindows 8 with VS2012 and Windows Azure Emulator version 2.0.0.

Ich bin dankbar, wenn mir jemand dabei helfen kann.

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

    Source: Microsoft.WindowsAzure.ServiceRuntime

    Stack Trace:    at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.get_IsAvailable()
       at Microsoft.ApplicationServer.Caching.AzureClientHelper.RoleUtility.IsAzureEnvironmentAvailable()

Stack Trace:    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Microsoft.ApplicationServer.Caching.DataCacheFactoryConfiguration.Initialize(String clientName)
   at Microsoft.ApplicationServer.Caching.DataCacheFactoryConfiguration..ctor()
   at Microsoft.ApplicationServer.Caching.DataCacheFactory..ctor()
   at Microsoft.ApplicationServer.Caching.DataCacheFactory.InitializeOrFetchSingletonFactoryInstance(String clientConfigurationName)
   at Microsoft.ApplicationServer.Caching.DataCache..ctor(String cacheName, String clientConfigurationName)
   at Microsoft.ApplicationServer.Caching.DataCache..ctor(String cacheName)
   at MvcWebRole.Controllers.HomeController.Index() in d:\Pankaj\Azure.Test\Caching.Sample\MvcWebRole\Controllers\HomeController.cs:line 15
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)

Antworten auf die Frage(3)

Ihre Antwort auf die Frage