Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
689 views
in Technique[技术] by (71.8m points)

c# - System.NotSupportedException when trying to create an asset

I am trying to use the Azure MediaService API along with the Azure Storage API in an API Service hosted in Azure.

The user sends the video stream to the service as an HttpPost, the service saves the video as a blob in my Storage account, the media service encodes the video and when the link to the video is ready it is returned to the user.

But when I am trying to create an Asset a System.NotSupportedException is thrown with the message:

Exception thrown: 'System.NotSupportedException' in Microsoft.Data.Services.Client.dll Exception thrown: 'System.NotSupportedException' in mscorlib.dll iisexpress.exe Error: 0 : Exception=System.NotSupportedException: This target framework does not enable you to directly enumerate over a data service query. This is because enumeration automatically sends a synchronous request to the data service. Because this framework only supports asynchronous operations, you must instead call the BeginExecute and EndExecute methods to obtain a query result that supports enumeration.

I am using the following versions of the required dependencies:

Microsoft.Data.Services.Client - 5.6.2.0
Microsoft.WindowsAzure.MediaServices.Client - 3.0.0.8
Microsoft.WindowsAzure.Storage - 3.1.0.1

Here is my code:

CloudMediaContext _context;
IAsset asset;
using (MemoryStream Ms = new MemoryStream(data.Data))
{
    _context = new CloudMediaContext("accountName", "accountKey");
    asset = await _context.Assets.CreateAsync("blobContainerName",
        AssetCreationOptions.None,CancellationToken.None);
    ...
    ...
}

The data.Data contains the byte[] of the video. The exception is thrown when CreateAsync is called. I tried _context.Assets.Create with no luck.

IMPORTANT EDIT

I created a new console application, used the code I am using in the API Service and it was executed successfully. So the problem is in the API Service.

Here is my class and method definitions

public class UploadController : ApiController
{

    [HttpPost]
    public async Task<string> PostUpload(VideoData data)
    {
        ...
        ...
    }

Any alternative to that maybe?

question from:https://stackoverflow.com/questions/30553366/system-notsupportedexception-when-trying-to-create-an-asset

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...