C# Issues and Solutions -- Method get_XXX from assembly YYYY does not have an implementation

本文通过一个具体的示例详细解释了TypeLoadException的发生原因及其复现步骤。通过创建接口定义与实现类库项目,并在客户端项目中引用这两种类库,演示了当实现类库针对不同版本的接口重新编译时如何引发TypeLoadException异常。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

This can occur if you have an interface in one assembly and its implementation in another, and the implementation assembly was built against a different version of the interface.

If you want to try reproducing this, try the following:
   1. Create a class library project: InterfaceDef, add just one class, and build:
      
   2. Create a second class library project: Implementation (with separate solution), copy InterfaceDef.dll into project directory and add as file reference, add just one class, and build:


   3. Create a third, console project: ClientCode, copy the two dlls into the project directory, add file references, and add the following code into the Main method:


   4. Run the code once, the console says "hello world"
   5. Uncomment the code in the two dll projects and rebuild - copy the two dlls back into the ClientCode project, rebuild and try running again. TypeLoadException occurs when trying to instantiate the ImplementingClass.

http://stackoverflow.com/questions/948785/typeloadexception-says-no-implementation-but-it-is-implemented

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值