Getting a connection error with a local emulator

In my Azure application, when I try to connect to a local emulator, I get an error.

The line of code with which I receive the message is:

CloudStorageAccount CSC = CloudStorageAccount.Parse( RoleEnvironment.GetConfigurationSettingValue("connection")); 

In CS Def

 <ConfigurationSettings> <Setting name="connection" /> </ConfigurationSettings> 

At .cscfg

 <Role name="WebRole1"> <Instances count="1" /> <ConfigurationSettings> <Setting name="connection" value="UseDevelopmentStorage=true" /> </ConfigurationSettings> 

Stack trace:

 at RdGetApplicationConfigurationSetting(UInt16* , UInt16** ) at RoleEnvironmentGetConfigurationSettingValueW(UInt16* pszName, UInt16* pszDest, UInt32 cchDest, UInt32* pcchRequiredDestSize) at Microsoft.WindowsAzure.ServiceRuntime.Internal.InteropRoleManager.GetConfigurationSetting(String name, String& ret) at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(String configurationSettingName) at WebRole1._Default.Page_Load(Object sender, EventArgs e) in c:\users\gowdes\documents\visual studio 2010\Projects\WindowsAzureProject20\WebRole1\Default.aspx.cs:line 19 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
+4
source share
2 answers

this may seem too simplistic ... but double-check that the default application is indeed your Cloud Application project and NOT an ASP.NET/Web project. Without a cloud context, you are bound to get a SHException or something like that.

+3
source

@Jim O'Neil has already indicated that you need to run the Cloud project, which is your launch project, to avoid a SEHException. I will also talk about SEHException in this SO answer .

Looking at your comment above, you said that your code falls into the else part:

 if (RoleEnvironment.IsAvailable) 

This means that the role environment (for example, Windows Azure) is unavailable and you cannot execute it:

 CloudStorageAccount CSC = CloudStorageAccount.Parse( RoleEnvironment.GetConfigurationSettingValue("connection")); 

This most likely reason is that the Cloud project is not a launch project. Or, perhaps the emulator does not start (what happens if you do not start Visual Studio as an administrator).

+2
source

Source: https://habr.com/ru/post/1398052/


All Articles