摘要:[Windows Azure]錯誤訊息:SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used
太久沒寫雲端程式,今天寫好程式一執行,居然遇到一個錯誤:
SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used
上網一查,原來原因是SDK 1.3版本之後就支援了Full IIS,
所以原本寫在WebRole.cs的OnStart()裡的CloudStorageAccount.SetConfigurationSettingPublisher,
要移到Global.asax的Application_Start(),程式碼如下:
protected void Application_Start(object sender, EventArgs e)
{
// configuration settings change in the service configuration file.
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
{
// Provide the configSetter with the initial value
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
});
}
參考:
http://msdn.microsoft.com/zh-tw/windowsazure/gg565829