Windows Azure Training Kit中"Introduction to Windows Azure"动手实验出现 System.Data.Services.Client.DataServiceClient

    技术2022-05-20  43

    在Windows Azure Training Kit中的第一个动手实验"Introduction to Windows Azure"运行时,可能出现下列错误:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <code>ResourceNotFound</code> <message xml:lang="zh-CN">The specified resource does not exist.</message></error> 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

    异常详细信息: System.Data.Services.Client.DataServiceClientException: <?xml version="1.0" encoding="utf-8" standalone="yes"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <code>ResourceNotFound</code> <message xml:lang="zh-CN">The specified resource does not exist.</message></error>

     

    经过调试检查,我认为GuestBookDataSource.cs文件中的静态构造函数中下列代码可能有问题:

    static GuestBookDataSource()        {            storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

                CloudTableClient.CreateTablesFromModel(                typeof(GuestBookDataContext),                storageAccount.TableEndpoint.AbsoluteUri,                storageAccount.Credentials);         }

    CloudTableClient.CreateTablesFromModel函数似乎没有在Windows Azure Storage中创建我们需要存储数据的Table。

    因此,我把上述代码替换为:

    static GuestBookDataSource()        {            storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

                CloudTableClient client = storageAccount.CreateCloudTableClient();            client.CreateTableIfNotExist("guestbookentities");        }

    其中,"guestbookentities"应该与GuestBookDataContext.cs文件中CreateQuery函数调用处提供的EntitySet名字一致。

    这样,便不再出现上述错误。


    最新回复(0)