echo ""; echo ""; echo ""; echo ""; if(!is_admin){echo "";} » 在Windows Azure中读取配置文件中的连接设置 仲子说

2011-08-01

在Windows Azure中读取配置文件中的连接设置

Posted in .NET at 11:40 Author:仲远

标签:

???Windows Azure???????????????????????Azure??????????????????????Azure???????

var storageAccount = CloudStorageAccount.FromConfigurationSetting(”DataConnectionString”);

???????????Azure??????????????????????SetConfigurationSettingPublisher??????????????????

Unhandled Exception: System.InvalidOperationException: ConfigurationSettingSubscriber needs to be set before FromConfigurationSetting can be used
at Microsoft.WindowsAzure.CloudStorageAccount.FromConfigurationSetting(String settingName)

???????????????????????SetConfigurationSettingPublisher?

?1????????Azure????????????????ServiceConfiguration.cscfg?????????????????????????????

CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSettingPublisher) =>
{
var connectionString = RoleEnvironment.GetConfigurationSettingValue(configName);
configSettingPublisher(connectionString);
}
);

?2????????C#?????app.config??web.config????????????????????????

CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
configSetter(ConfigurationManager.AppSettings[configName]));

?????????????????CloudStorageAccount???Azure???????????????????????????????????WebRole??????????Global.asax???void Application_Start(object sender, EventArgs e)????????WorkRole???????????????????????

本文可以自由转载,转载时请保留全文并注明出处:
转载自仲子说 [ http://www.wangzhongyuan.com/ ]
原文链接:

Leave a Comment

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word