4

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)
Michael Wiles
  • 20,902
  • 18
  • 71
  • 101
user712094
  • 71
  • 1
  • 7
  • i am getting error as `"{"External component has thrown an exception."}"` this is coming under system.runtime.interopservice.SHEexception – user712094 Feb 24 '12 at 08:47
  • one more this when i am checking for its going else part ` if (RoleEnvironment.IsAvailable) { CloudStorageAccount CSC = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Con")); } else { }` – user712094 Feb 24 '12 at 09:19

2 Answers2

3

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.

Jim O'Neil
  • 23,344
  • 7
  • 42
  • 67
2

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

Community
  • 1
  • 1
David Makogon
  • 69,407
  • 21
  • 141
  • 189