Search code examples
c#azurevisual-studio-2013windows-store-appsazure-storage

Azure StorageException is inaccessible due to its protection level


Looks like something wrong with my VS2013, because this code:

try
{
    TableResult tblr = await cloudTable.ExecuteAsync(...);
}
catch ( StorageException ex )
{
    Debug.WriteLine( ex.Message );
}

Gives me this error:

Microsoft.WindowsAzure.Storage.StorageException is inaccessible due to its protection level

Everything else is working well in this windows store project. It even works in the console application, that use almost the same azure code (StorageException works well in the console application).

Any ideas what can be wrong? I tried to reinstall Azure Sdk 2.5, delete ComponentModelCache folder in VS2013 - nothing helped.

Update: I'm not 100% sure, but Azure library code declares StorageException in this way:

#if WINDOWS_RT || ASPNET_K
    internal class StorageException : COMException
#else
    public class StorageException : Exception
#endif

It's looks like Windows Store app is the same as WINDOWS_RT.


Solution

  • Azure Storage Client Library for Windows Runtime does not expose the StorageException type, because Windows Runtime components are not allowed to declare public exception types (see Throwing exceptions for more information).

    You can instead pass in an OperationContext object and then check its LastResult.