【问题标题】:Azure Storage SDK for .NET gives error when compiled with .Net Native in UWP app在 UWP 应用中使用 .Net Native 编译时,适用于 .NET 的 Azure 存储 SDK 会出错
【发布时间】:2016-11-07 23:34:28
【问题描述】:

我在 Windows 应用商店中有一个 UWP 应用,我相信 Windows 应用商店会在将应用交付给用户设备之前使用 .Net Native 工具链编译应用。

我的代码从存储表中插入/更新/删除一个对象,它得到以下错误。

System.NotSupportedException: NotSupported_UnreadableStream. 
For more information, visit http://go.microsoft.com/fwlink/?LinkId=623485

at System.IO.Stream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, Threading.CancellationToken cancellationToken)

at Microsoft.WindowsAzure.Storage.Core.NonCloseableStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, Threading.CancellationToken cancellationToken)

代码如下:

删除操作:

await AzureStorageTable.ExecuteAsync(TableOperation.Delete(myObject));

插入/更新操作:

await DeletesStorageTable.ExecuteAsync(TableOperation.InsertOrReplace(myObject));

感谢您提前提供帮助。

【问题讨论】:

    标签: azure azure-storage azure-table-storage .net-native


    【解决方案1】:

    我写了一个简单的代码。它在我的 UWP 环境中运行良好。示例代码如下:

            //Get Entity and set IEntity
    TableOperation retrieveOperation = TableOperation.Retrieve<CustomerEntity>("Harp", "Walter");
                var retrieveResult = await table.ExecuteAsync(retrieveOperation);
                ITableEntity ite = (CustomerEntity)retrieveResult.Result;
    
    //Delete Entity
            TableOperation deleteOperation = TableOperation.Delete(ite);
            await table.ExecuteAsync(deleteOperation);
    

    根据你的描述,我觉得你应该注意两点:

    1. 请确保您的表中有您要删除的对象。

    2. 请确保 'myObject' 具有 Tag 属性。因为删除和更新功能需要这个属性。

    谢谢。

    【讨论】:

    • 您好,表操作仅在使用 .Net Native 工具链在发布模式下编译时不起作用。
    猜你喜欢
    • 2015-12-22
    • 2016-07-09
    • 2019-04-24
    • 2016-04-17
    • 2018-02-19
    • 2016-05-07
    • 2016-05-28
    • 2016-07-10
    • 2018-05-08
    相关资源
    最近更新 更多