我有一个非常奇怪的问题。我在一个dll中定义了一个接口,如下所示:
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();
}
如果我在我的WPF应用程序中链接到这个dll,调试器会在加载时崩溃(内部错误:调试器::HandleIPCEvent中未处理的异常,ID=0x246)。如果我使用“调试非托管代码”调试应用程序,我会得到以下错误:
- 在InfiniRender.Host.exe中的0x76977945(KernelBase.dll)处第一次机会异常:Microsoft C++异常:EETypeLoadException,内存位置为0x0029c5b8。
- 在InfiniRender.Host.exe中的0x76977945(KernelBase.dll)处第一次机会异常:Microsoft C++异常:[重新抛出],内存位置为0x00000000。
- 在InfiniRender.Host.exe中发生了类型为'System.TypeLoadException'的第一个机会异常
- 在InfiniRender.Host.exe中发生了类型为'System.TypeLoadException'的未处理异常,附加信息:Nicht abstrakte Nicht-.cctor-Methode in einer Schnittstelle。
目前我完全不知道发生了什么。甚至没有接口的实现,也没有类使用它。如果我注释掉“Init”方法,一切都按预期工作。 有任何想法吗??
[编辑] 这是接口init方法的MSIL:
.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
我觉得,问题可能是由NLog引起的?直到今天,我从未遇到过任何关于NLog的问题...