距離上次看Windows Azure有一段時間了,今天在用VS2010建立Windows Azure時出現了不少問題,這裡做個記錄。
首先是建立好Windows Azure模版項目,啟動調試時Windows Azure儲存模擬器初始化失敗,錯誤資訊為:
Failed to initialize Windows Azure storage emulator.
其實按照錯誤資訊中的提示,查看output視窗,資訊如下:
output window:
Windows Azure Tools: Failed to initialize Windows Azure storage emulator. Unable to start Development Storage. Failed to start Storage Emulator: the SQL Server instance ‘localhost\SQLExpress’ could not be found. Please configure the SQL Server instance for Storage Emulator using the ‘DSInit’ utility in the Windows Azure SDK.
這個Windows Azure儲存模擬器需要本地的Sql Express,我平時為了節省資源把Sql Server服務全部都停掉了。但發現啟動服務後還是有問題,於是按照錯誤資訊中的提示,運行一下DSInit命令還重新初始化儲存模擬器:
在Visual Studio Command Prompt (2010)命令列工具中輸入:
cd C:\Program Files\Windows Azure Emulator\emulator\devstore
DSInit /forcecreate
執行結果如下,初始化成功。
然後啟動調試,前面的錯誤資訊消失。
這是如果用Sql Server management studio開啟Sql Express,會發現其中有個一個資料庫DevelopmentStorageDb20110816,
但是頁面並未運行正常,而是出現如下錯誤資訊:
Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
放狗搜了一下,找到
http://support.microsoft.com/kb/2015129中解釋了原因和解決辦法。也許我在安裝好.net framework 4.0後,因為某些原因有安裝了更低版本的.net架構。解決辦法就是用asp.net 4.0重新註冊IIS:
cmd視窗中運行
aspnet_regiis.exe /iru
aspnet_regiis位於如下位置:
%windir%\Microsoft.NET\Framework\v4.0.30319
%windir%\Microsoft.NET\Framework64\v4.0.30319 (64位)
到此環境又恢複了正常。