What is the reason why I get "Non abstract, non-.cctor-method in an interface"?

I have a very strange problem. I have an interface defined in a dll as follows:

public interface IKreator2 { string Name { get; set; } string Description { get; set; } INotifyPropertyChanged Settings { get; set; } InfiniRenderJob Job { get; set; } UserControl UI { get; set; } void Init(); //void OnClose(); } 

If I reference this DLL in my WPF application, the Debugger crashes on loading (Internal Error: Unhandled Exception in the debugger :: HandleIPCEvent, ID = 0x246). If I debug the application using "debugging unmanaged code", I get the following errors:

  • First chance exception at 0x76977945 (KernelBase.dll) in InfiniRender.Host.exe: Microsoft C ++ exception: EETypeLoadException in memory location 0x0029c5b8.
  • First chance exception in 0x76977945 (KernelBase.dll) in InfiniRender.Host.exe: Microsoft C ++ exception: [rethrow] in memory location 0x00000000.
  • The first random ype 'System.TypeLoadException' error occurred in the InfiniRender.Host.exe file
  • An unhandled exception of type "System.TypeLoadException" occurred in InfiniRender.Host.exe Additional information: Nicht abstrakte Nicht-.cctor-Methode in einer Schnittstelle.

At the moment, I absolutely do not understand what is happening. There is not even an implantation of an interface, and no class uses it. If I comment on the "Init" method, everything will work as expected. Any ideas?

[EDIT] This is the MSIL for the interface init method:

 .method public hidebysig newslot virtual instance void Init() cil managed { // Code size 96 (0x60) .maxstack 3 .locals init ([0] class [mscorlib]System.Exception CS$0$0__ex) IL_0000: ldsfld class [NLog]NLog.Logger '<>z__LoggingImplementationDetails'::l14 IL_0005: callvirt instance bool [NLog]NLog.Logger::get_IsTraceEnabled() IL_000a: brfalse.s IL_001b IL_000c: ldsfld class [NLog]NLog.Logger '<>z__LoggingImplementationDetails'::l14 IL_0011: ldstr "Entering: InfiniRender.IKreator2.Init()" IL_0016: call instance void [NLog]NLog.Logger::Trace(string) .try { IL_001b: newobj instance void [mscorlib]System.NotSupportedException::.ctor() IL_0020: throw IL_0021: ldsfld class [NLog]NLog.Logger '<>z__LoggingImplementationDetails'::l14 IL_0026: callvirt instance bool [NLog]NLog.Logger::get_IsTraceEnabled() IL_002b: brfalse.s IL_003c IL_002d: ldsfld class [NLog]NLog.Logger '<>z__LoggingImplementationDetails'::l14 IL_0032: ldstr "Leaving: InfiniRender.IKreator2.Init()" IL_0037: call instance void [NLog]NLog.Logger::Trace(string) IL_003c: leave.s IL_005f } // end .try catch [mscorlib]System.Exception { IL_003e: ldsfld class [NLog]NLog.Logger '<>z__LoggingImplementationDetails'::l14 IL_0043: callvirt instance bool [NLog]NLog.Logger::get_IsWarnEnabled() IL_0048: brfalse.s IL_005d IL_004a: stloc.0 IL_004b: ldsfld class [NLog]NLog.Logger '<>z__LoggingImplementationDetails'::l14 IL_0050: ldstr "An exception occurred:\n{0}" IL_0055: ldloc.0 IL_0056: call instance void [NLog]NLog.Logger::Warn(string, object) IL_005b: rethrow IL_005d: leave.s IL_005f } // end handler IL_005f: ret } // end of method IKreator2::Init 

It seems to me that NLog is to blame? There has never been a problem with NLog until today ...

+6
source share
1 answer

So, the culprit here was Messageharp.Diagnostics.Toolkit, which added codes to the interface method declarations, which led to the debugger chaos.

Thanks to everyone who helped!

+2
source

Source: https://habr.com/ru/post/920959/


All Articles