다음 코드에서 위의 오류가 발생합니다. 그것을 바로 잡는 방법. 감사. 아래 코드에서오류 : object.Finalize를 재정의하지 마십시오. 대신 소멸자를 제공하십시오.
protected override void Finalize() { Dispose(false); }
을 찾아보십시오.
using Microsoft.Win32;
using System.Runtime.InteropServices;
public class Kiosk : IDisposable
{
#region "IDisposable"
// Implementing IDisposable since it might be possible for
// someone to forget to cause the unhook to occur. I didn't really
// see any problems with this in testing, but since the SDK says
// you should do it, then here's a way to make sure it will happen.
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing) {
}
// Free other state (managed objects).
if (m_hookHandle != 0) {
UnhookWindowsHookEx(m_hookHandle);
m_hookHandle = 0;
}
if (m_taskManagerValue > -1) {
EnableTaskManager();
}
}
protected override void Finalize()
{
Dispose(false);
}
#endregion
}
+1 왜 그냥 코드를 덤핑하는 대신에 대해 언급합니다. –
글쎄, 그는 실제로 왜 언급하지 않습니다. 예외 자체는 같은 것을 말한다. –