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...

Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
f0rt1s
  • 396
  • 1
  • 3
  • 12
  • What does the raw IL for that interface say? – thecoop Jul 20 '12 at 11:59
  • can u upload a repro somewhere? – Simon Jul 20 '12 at 12:15
  • 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. – casperOne Jul 20 '12 at 13:16

1 Answers1

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!

f0rt1s
  • 396
  • 1
  • 3
  • 12
  • I had the same error. Thanks for your answer. I've posted my suggestion to http://support.sharpcrafters.com/discussions/suggestions/5-default-psproj-in-toolkit-should-exclude-interfaces – Michael Freidgeim Aug 09 '12 at 12:24