user712094
user712094

Reputation: 71

Getting connection error with local emulator

In my Azure application when I am trying to connect to local emulator, I am getting an error.

The line of code I am getting the error on is:

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

In CS Def

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

In .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)

Upvotes: 4

Views: 1960

Answers (2)

David Makogon
David Makogon

Reputation: 71130

@Jim O'Neil already pointed out that you need to run with the Cloud project being your startup project to avoid SEHException. I also talk about SEHException in this SO answer.

Looking at your comment above, you said your code hits the else part of:

if (RoleEnvironment.IsAvailable)

That means the role environment (e.g. Windows Azure) is not available and you won't be able to execute:

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

This most likely reason is because the Cloud project is not the startup project. Or, possibly the emulator isn't being launched (which happens if you don't run Visual Studio as Administrator).

Upvotes: 2

Jim O&#39;Neil
Jim O&#39;Neil

Reputation: 23784

this may seem overly simplistic... but double check that the default application is indeed your Cloud Application project and NOT the ASP.NET/Web project. Without the "Cloud" context, you'll definitely get the SHException or something similar.

Upvotes: 3

Related Questions