C# 使用动态方法param实现接口时xUnit System.TypeLoadException
我有一个引用的nuget包,其中包含一个接口:C# 使用动态方法param实现接口时xUnit System.TypeLoadException,c#,.net-core,dynamic,xunit,typeloadexception,C#,.net Core,Dynamic,Xunit,Typeloadexception,我有一个引用的nuget包,其中包含一个接口: public interface IMyInterface { bool Initialize(Dictionary<string, dynamic> initArguments); } 但如果我尝试在单元测试项目中使用它,则是: System.TypeLoadException:程序集“xxx,版本=1.0.0.0,区域性=中性,PublicKeyToken=null”中类型“xxx.MyImplementation”中的方
public interface IMyInterface {
bool Initialize(Dictionary<string, dynamic> initArguments);
}
但如果我尝试在单元测试项目中使用它,则是:
System.TypeLoadException:程序集“xxx,版本=1.0.0.0,区域性=中性,PublicKeyToken=null”中类型“xxx.MyImplementation”中的方法“Initialize”没有实现
这是我的单元测试:
[Fact]
public void Test1()
{
var myImplementation = new MyImplementation();
Assert.NotNull(myImplementation);
}
我认为这可能是因为字典
参数,与动态
相关,但不确定。我有谷歌它很多没有运气
更新
如果我检查从nuget包引用的接口,它是这样的:
public interface IMyInterface {
bool Initialize([Dynamic(new[] { false, false, true })] Dictionary<string, dynamic> initArguments);
}
公共接口IMyInterface{
bool初始化([Dynamic(new[]{false,false,true})]字典初始化参数);
}
我不知道nuget包的编译版本为什么是这样,参数中有Dynamic
data属性
[Fact]
public void Test1()
{
var myImplementation = new MyImplementation();
Assert.NotNull(myImplementation);
}
public interface IMyInterface {
bool Initialize([Dynamic(new[] { false, false, true })] Dictionary<string, dynamic> initArguments);
}