المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Exception while creating table in azure.



C# Programming
10-02-2009, 09:41 AM
I'm trying to learn and work on azure table storage. The code works perfectly in my local. When I configure to the azure and still trying to work with my local (not using publish), I'm getting an exception.

public bool DoesTableExist(string tableName)
{
ParameterValidator.CheckStringParameter(tableName, false, "tableName");
bool tableExists = false;

RetryPolicy(() =>
{
try
{
DataServiceContext svc = GetDataServiceContext();
svc.MergeOption = MergeOption.NoTracking;
IEnumerable query = from t in svc.CreateQuery(TableStorageConstants.TablesName)
where t.TableName == tableName
select t;
tableExists = false;
try
{
// the query contains the whole primary key
// thus, if the query succeeds we can be sure that the table exists
(query as DataServiceQuery).Execute(); tableExists = true;
}
catch (DataServiceQueryException e)
{
HttpStatusCode s;
if (TableStorageHelpers.EvaluateException(e, out s) && s == HttpStatusCode.NotFound)
{
tableExists = false;
}
else
{
throw;
}
}
catch (NullReferenceException ne)
{
//This is a workaround for bug in DataServiceQuery.Execute. It throws a
//NullReferenceException instead of a DataServiceRequestException when it
//cannot connect to the the server. This workaround will be removed when
//the fix for this bug is released.
throw new DataServiceRequestException("Unable to connect to server.", ne);
}
}
catch (InvalidOperationException e)
{
HttpStatusCode status;
if (TableStorageHelpers.CanBeRetried(e, out status))
{
throw new TableRetryWrapperException(e);
}
throw;
}
});
return tableExists;
}

when it executes the (query as DataServiceQuery<TableStorageTable&gthttp://www.barakasoft.com/script/Forums/Images/smiley_wink.gif.Execute() it has to fail and come to DataServiceQueryException and make tableExists = false and return with the same to create the table. Instead the code goes to the catch (NullReferenceException ne)and says unable to connect to the server. can someone help me onthis please.Thanks.