开发者

System.TypeLoadException - Method get_*** in type *** from assembly *** does not have an implementation when it does? [duplicate]

开发者 https://www.devze.com 2023-03-09 03:22 出处:网络
This question already has answers here: TypeLoadException says 'no implementation', but it is implemented
This question already has answers here: TypeLoadException says 'no implementation', but it is implemented (41 answers) Closed 7 years ago.

I am using the program Reflexil to inject a reference in the executable Foo1.exe to an outside assembly named Foo2.dll.

In Foo1.exe, there is a class called Bar.

In Foo2.dll, there is an interface IBar which correctly implements all of the fields and methods of Bar.

I have used Reflexil to give Bar in Foo1.exe the interface IBar in Foo2.dll.

When Foo1开发者_如何转开发.exe loads, it finds Foo2.dll located in the application directory and loads it, but it throws a System.TypeLoadException with the following error message Method 'get_***' in type 'Foo1.Bar' from assembly 'Foo1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

I have already read through the previous question with the same error message (TypeLoadException says 'no implementation', but it is implemented), but I've been unable to figure out how to correctly implement the fix when I don't have any compiler checks for Foo1.exe.

Thanks for your help!


I've got the same error message in the following situation: A.dll depends on B.dll, B.dll depends on C.dll and C.dll is not found. In my case A.dll contains a class C2 derived from abstract class C1 located in the same assembly and in the same dll - A.dll. C1 is derived from C0 class from B.dll. C0 has abstract property with abstract getter method, C1 has an implementation of this property but the matter is that return type of the property's getter is defined in the absent library C.dll. Finaly, it leads to the error message "Method 'get_Prop' in type 'C2' from assembly 'A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxx' does not have an implementation." which is rather irrelevant in this situation. In short the source code looks like this:

C.dll:

namespace C {
  public enum PropType {V1 = 0, V2 = 1, ...}
}

B.dll:

using C;
namespace B {
  public abstract class C0 {
    ...
    public abstract C.PropType Prop {get;}
  }
}

A.dll:

using C;
using B;
namespace A {
  public abstract class C1 : B.C0 {
    ...
    // Getter implementation
    public override C.PropType Prop { get {return C.PropType.V1;}}
  }
}

using C;
using B;
namespace A {
  // Class implementation
  public class C2 : C1 {
    ...
  }
}

So the solution is to add C.dll to the installation.

0

精彩评论

暂无评论...
验证码 换一张
取 消