Tôi có một vấn đề rất lạ. Tôi có một giao diện được định nghĩa trong một dll như sau:Lý do tôi nhận được "Phương thức không trừu tượng, không phải .cctor trong giao diện" là gì?
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();
}
Nếu tôi liên kết với dll này trong WPF của tôi app crashes Debugger trên tải (Internal Error: Unhandled Exception trong debugger :: HandleIPCEvent, ID = 0x246) . Nếu tôi gỡ lỗi các ứng dụng với "mã unmanaged debug" tôi nhận được các lỗi sau đây:
- First-cơ hội ngoại lệ tại 0x76977945 (KernelBase.dll) trong InfiniRender.Host.exe: Microsoft C++ ngoại lệ: EETypeLoadException tại bộ nhớ vị trí 0x0029c5b8.
- Trường hợp ngoại lệ đầu tiên tại 0x76977945 (KernelBase.dll) trong InfiniRender.Host.exe: Microsoft C++ ngoại lệ: [rethrow] tại bộ nhớ vị trí 0x00000000.
- Một ngoại lệ cơ hội đầu tiên của ype 'System.TypeLoadException' xảy ra trong InfiniRender.Host.exe
- Một ngoại lệ unhandled của loại 'System.TypeLoadException' xảy ra ở InfiniRender.Host.exe thông tin bổ sung: Nicht abstrakte Nicht -.cctor-Methode trong einer Schnittstelle.
Tại thời điểm tôi hoàn toàn không có đầu mối gì đang xảy ra. Thậm chí không có một implentation của giao diện và không có lớp sử dụng nó. Nếu tôi nhận xét phương thức "Init", mọi thứ sẽ hoạt động như mong đợi. Bất kỳ ý tưởng nào ??
[EDIT] Đây là MSIL cho phương pháp giao diện init:
.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
Dường như với tôi, rằng NLog là để đổ lỗi? Chưa bao giờ có bất kỳ vấn đề nào với NLog cho đến hôm nay ...
IL thô cho giao diện đó nói gì? – thecoop
bạn có thể tải lên một repro ở đâu đó không? – Simon
Bạn tiêu thụ * giao diện này như thế nào? Bạn có lỗi ngụ ý một số mã không được quản lý. Ngoài ra, các trường hợp 'TypeLoadException' có nhiều khả năng không phải do giao diện *, mà là mã * thực hiện * giao diện. – casperOne