与本地模拟器发生连接错误
在我的 Azure 应用程序中,当我尝试连接到本地模拟器时,出现错误。
我收到错误的代码行是:
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能看起来过于简单......但请仔细检查默认应用程序确实是您的云应用程序项目而不是 ASP.NET/Web 项目。如果没有“Cloud”上下文,您肯定会得到 SHException 或类似的东西。
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 已经指出,您需要将 Cloud 项目作为启动项目来运行,以避免 SEHException。我还在这个SO答案中讨论了SEHException。
看看您上面的评论,您说您的代码命中了以下部分的
else
部分:这意味着角色环境(例如 Windows Azure)不可用,您将无法执行:
这最有可能的原因是因为Cloud项目不是启动项目。或者,模拟器可能未启动(如果您不以管理员身份运行 Visual Studio,则会发生这种情况)。
@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:That means the role environment (e.g. Windows Azure) is not available and you won't be able to execute:
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).