在Amazon lambda函数中使用反射从二进制数组加载汇编



在我的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);

但是现在,当我尝试调用方法"ABC"从"obj"变量

//
// this doesn't work!
obj.ABC();

我收到以下错误:系统。MissingMethodException: Method not found "AmazonDynamoDBClient">

方法"obj.ABC()"正在使用"AmazonDynamoDBClient"的实例,所以很明显,dotnet不能解决这个依赖关系。

我发现了这篇微软的文章:https://learn.microsoft.com/en-us/dotnet/framework/deployment/best-practices-for-assembly-loading但我不清楚如何解决依赖当我使用Assembly.Load(binary_array)

如何解决变量"obj"还是它的阶级需求?

我找到了一些可以帮助你的信息

* *https://learn.microsoft.com/en us/dotnet/api/system.reflection.assembly.load?view=net - 5.0

public static System.Reflection.Assembly Load (byte[] rawAssembly);