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

1

6

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 link to this dll in my WPF app the Debugger crashes on load (Internal Error: Unhandled Exception in the debugger::HandleIPCEvent, ID=0x246). If I debug the app with "debug unmanaged code" I get the following errors:

  • First-chance exception at 0x76977945 (KernelBase.dll) in InfiniRender.Host.exe: Microsoft C++ exception: EETypeLoadException at memory location 0x0029c5b8.
  • First-chance exception at 0x76977945 (KernelBase.dll) in InfiniRender.Host.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
  • A first chance exception of ype 'System.TypeLoadException' occurred in InfiniRender.Host.exe
  • 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 have absolutly no clue what is going on. There isnt even an implentation of the interface and no class uses it. If I comment the method "Init" out, everything works 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? Never had any issues with NLog until today...

Gauche answered 20/7, 2012 at 11:44 Comment(3)
What does the raw IL for that interface say?Sisterly
can u upload a repro somewhere?Joule
How are you consuming this interface? You errors imply some unmanaged code. Also, the TypeLoadException instances are more than likely not due to the interface, but to the code that implements the interface.Aronarondel
G
2

So, the culprit here was the "Postsharp.Diagnostics.Toolkit", which added code to interface method declarations resulting in Debugger mayhem.

Thanks to all who helped!

Gauche answered 20/7, 2012 at 14:24 Comment(1)
I had the same error. Thanks for your answer. I've posted my suggestion to support.sharpcrafters.com/discussions/suggestions/…Dichlamydeous

© 2022 - 2024 — McMap. All rights reserved.