简体   繁体   English

AWS .NET SDK DynamoDB LoadAsync返回“无法加载类型”错误

[英]AWS .NET SDK DynamoDB LoadAsync returning 'Could not load type' error

I'm developing an application using AWS Lambda and DynamoDB. 我正在使用AWS Lambda和DynamoDB开发应用程序。 I'm getting the error below when I try to test my lambda function. 尝试测试lambda函数时出现以下错误。

Error: 错误:

{ "errorType": "AggregateException", "errorMessage": "One or more errors occurred. (Could not load type 'Amazon.Runtime.Internal.AsyncRunner' from assembly 'AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'.)", "stackTrace": [ "at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)", "at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)", "at ProChiller.SyncDevices.QueryDevices(Devices input)", "at lambda_method(Closure , Stream , Stream , ContextInfo )" ], "cause": { "errorType": "TypeLoadException", "errorMessage": "Could not load type 'Amazon.Runtime.Internal.AsyncRunner' from assembly 'AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'.", "stackTrace": [ "at Amazon.DynamoDBv2.DataModel.DynamoDBContext.LoadAsync[T](Object hashKey, CancellationToken cancellationToken)", "at ProChiller.SyncDevices.d__6.MoveNext()" ] } } {“ errorType”:“ AggregateException”,“ errorMessage”:“发生一个或多个错误。(无法从程序集” AWSSDK.Core,Version = 3.3.0.0,Culture = neutral“加载类型'Amazon.Runtime.Internal.AsyncRunner' ,PublicKeyToken = 885c28607f98e604'。“”,“ stackTrace”:[“在System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)”,“在System.Threading.Tasks.Task.Wait(Int32毫秒超时,CancellationToken取消令牌)” ,“在ProChiller.SyncDevices.QueryDevices(设备输入)”,“在lambda_method(Closure,Stream,Stream,ContextInfo)”],“原因”:{“ errorType”:“ TypeLoadException”,“ errorMessage”:“无法加载从程序集“ AWSSDK.Core,版本= 3.3.0.0,文化=中性,PublicKeyToken = 885c28607f98e604”中输入“ Amazon.Runtime.Internal.AsyncRunner”。“,” stackTrace“:[”在Amazon.DynamoDBv2.DataModel.DynamoDBContext.LoadAsync [T](Object hashKey,CancellationToken cancelleToken)“,”在ProChiller.SyncDevices.d__6.MoveNext()“]}}

As you can see it seems to not be able to load 'AsyncRunner' from the AWSSDK. 如您所见,它似乎无法从AWSSDK加载“ AsyncRunner”。

Code: 码:

private static AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient();

public static Devices GetDeviceHandler(Devices input, ILambdaContext context)
{
     var task = QueryDevices(input);
     task.Wait();
     return task.Result;   
}

static async Task<Devices> QueryDevices(Devices device)
{
    DynamoDBContext dbctx = new DynamoDBContext(amazonDynamoDBClient);
    var operation = dbctx.LoadAsync<Devices>(device.TccvID);
    Devices devices = await operation;
    return devices;
}

What I've Tried: 我尝试过的

I tried a number of different ways of querying with Dynamo, but this method is the cleanest and normally gets me the results I'm looking for. 我尝试了多种不同的Dynamo查询方式,但是这种方法最干净,通常可以为我提供所需的结果。

Now I swear I had this code or very similar code working before at one point and I have in the past had issues with the SDK version causing problems when it was updated. 现在,我发誓我曾经有一段这段代码或非常相似的代码可以正常工作,并且过去我在SDK版本方面遇到问题,导致在更新时出现问题。 I tried rolling back the version of the AWSSDK.Core to see if it was a problem with the newer version of it and my code. 我尝试回滚AWSSDK.Core的版本,以查看它的新版本和我的代码是否有问题。 However, no matter what version I rollback to I still get the same error. 但是,无论我回滚到哪个版本,我仍然会遇到相同的错误。

I've googled around in hopes that someone had a similar issue with that type load , but I could find anyone having written about this specific error or one similar enough that I could extrapolate. 我四处搜寻,希望有人对此类型加载有类似的问题,但是我可以找到有人写过关于此特定错误或足够类似的东西以供我推断。 I was hoping maybe there was documentation of a specific SDK version I should be running for this type, but was not able to find anything. 我希望可能有针对该类型的特定SDK版本的文档,但找不到任何东西。

The code I've posted is actually a paired down version where I tried to make it as simple as possible in hopes that there was something else I was doing that was causing this error. 我发布的代码实际上是一个配对版本,在该版本中,我尝试使其尽可能简单,以希望我正在做的其他事情导致此错误。

Other Build Info: 其他构建信息:

The application is .Net Core 1.0. 该应用程序是.Net Core 1.0。

AWSSDK.Core version is 3.3.24.3, but I do notice that in the error is says 'version=3.3.0.0'. AWSSDK.Core版本为3.3.24.3,但我确实注意到错误中的内容是“ version = 3.3.0.0”。

The Question: 问题:

Does anyone have an idea what might be causing this type load error? 有谁知道是什么原因导致这种类型的加载错误? Is there a specific version of the SDK I should roll back to in order to fix this or am I barking up the wrong tree? 我应该回滚到特定版本的SDK来解决此问题,还是我搞错了树?

Thanks in advance for any help! 在此先感谢您的帮助!

Short answer is I think you need to update to a newer version of AWSSDK.DynamoDBv2. 简短的答案是,我认为您需要更新到更新版本的AWSSDK.DynamoDBv2。

We had a pull request that removed the need for AsyncRunner from AWSSDK.Core that AWSSDK.DynamoDBv2 needed and so it was removed. 我们有一个拉取请求,从AWSSDK.DynamoDBv2所需的AWSSDK.Core中删除了对AsyncRunner的需求,因此将其删除。 In hindsight seeing your problem it wasn't the right decision to remove. 事后发现您的问题不是正确的决定。 If you update both your AWSSDK.Core and AWSSDK.DynamoDBv2 packages you would have been fine but in this case you updated just AWSSDK.Core but your older version of AWSSDK.DynamoDBv2 is still referencing AsyncRunner from AWSSDK.Core. 如果同时更新AWSSDK.Core和AWSSDK.DynamoDBv2软件包,则可以,但在这种情况下,您仅更新了AWSSDK.Core,但旧版本的AWSSDK.DynamoDBv2仍从AWSSDK.Core引用AsyncRunner。

I'll have a discussion with the team and see about adding back AsyncRunner for cases like this. 我将与团队讨论,并了解有关在这种情况下重新添加AsyncRunner的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM