与本地模拟器发生连接错误

发布于 2025-01-08 01:40:58 字数 1640 浏览 0 评论 0原文

在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我的痛♀有谁懂 2025-01-15 01:40:58

这可能看起来过于简单......但请仔细检查默认应用程序确实是您的云应用程序项目而不是 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.

葬花如无物 2025-01-15 01:40:58

@Jim O'Neil 已经指出,您需要将 Cloud 项目作为启动项目来运行,以避免 SEHException。我还在这个SO答案中讨论了SEHException。

看看您上面的评论,您说您的代码命中了以下部分的 else 部分:

if (RoleEnvironment.IsAvailable)

这意味着角色环境(例如 Windows Azure)可用,您将无法执行:

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

这最有可能的原因是因为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:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文