【发布时间】:2021-11-04 19:37:51
【问题描述】:
在我的 C# aws lambda 函数中,我使用带有二进制数组的 Assembly.Load()。我执行以下操作:
//
// "item" is an object that has the property "DotNetAssembly" with
// the binary array that has the assembly that I need to load
//
// this works perfectly!
var assembly = AppDomain.CurrentDomain.Load(item.DotNetAssembly)
现在我从“程序集”变量创建一个实例:
//
// "item" is an object that has a property "DotNetType"
// with the name of the class that I need to instance
//
// this works perfectly!
var obj = assembly.CreateInstance(item.DotNetType);
但是现在,当我尝试从“obj”变量中调用方法“ABC”时
//
// this doesn't work!
obj.ABC();
我收到以下错误: System.MissingMethodException:找不到方法“AmazonDynamoDBClient”
“obj.ABC()”方法正在使用“AmazonDynamoDBClient”的一个实例,因此很明显 dotnet 无法解析这种依赖关系。
我找到了这篇微软的文章: https://docs.microsoft.com/en-us/dotnet/framework/deployment/best-practices-for-assembly-loading 但我不清楚使用 Assembly.Load(binary_array) 时如何解决依赖关系
如何解决变量“obj”或其类所需的依赖关系?
【问题讨论】:
标签: c# reflection aws-lambda