C# 获取本地仿真器的连接错误
在Azure应用程序中,当我尝试连接到本地emulator时,出现了一个错误 我得到的错误代码行是:C# 获取本地仿真器的连接错误,c#,azure,azure-table-storage,C#,Azure,Azure Table Storage,在Azure应用程序中,当我尝试连接到本地emulator时,出现了一个错误 我得到的错误代码行是: CloudStorageAccount CSC = CloudStorageAccount.Parse( RoleEnvironment.GetConfigurationSettingValue("connection")); 在CS Def中 <ConfigurationSettings> <Setting name="connection" />
CloudStorageAccount CSC = CloudStorageAccount.Parse(
RoleEnvironment.GetConfigurationSettingValue("connection"));
在CS Def中
<ConfigurationSettings>
<Setting name="connection" />
</ConfigurationSettings>
这似乎过于简单化了。。。但是,请仔细检查默认应用程序是否确实是您的云应用程序项目,而不是ASP.NET/Web项目。如果没有“云”上下文,您肯定会得到SHException或类似的东西。@Jim O'Neil已经指出,您需要将云项目作为启动项目来运行,以避免sexception。我还谈到了sehexin 查看上面的评论,您说您的代码点击了以下部分的
else
:
if(RoleEnvironment.IsAvailable)
这意味着角色环境(如Windows Azure)不可用,您将无法执行:
CloudStorageAccount CSC=CloudStorageAccount.Parse(
GetConfigurationSettingValue(“连接”);
这很可能是因为云项目不是启动项目。或者,可能没有启动仿真器(如果您不是以管理员身份运行Visual Studio,则会发生这种情况)。我收到错误,因为
“{”外部组件引发了异常。“}”
这是在system.runtime.interopservice.SheeException下,当我检查其going else部分`如果(RoleEnvironment.IsAvailable){CloudStorageAccount CSC=CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(“Con”);}其他{}`我通过将windowazure设置为启动项目进行了检查,但仍然无法正常工作:(
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="connection" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
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)