距离上次看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位)
到此环境又恢复了正常。