Memory Leak in C#

Event Handlers are a very common source of non-obvious memory leaks. If you subscribe to an event on object1 from object2, then do object2.Dispose() and pretend it doesn’t exist (and drop out all references from your code), there is an implicit reference in object1’s event that will prevent object2 from being garbage collected. MyType object2 … Read more

WinApi – GetLastError vs. Marshal.GetLastWin32Error

You must always use the Marshal.GetLastWin32Error. The main problem is the garbage collector. If it runs between the call of SetVolumeLabel and the call of GetLastError then you will receive the wrong value, because the GC has surely overwritten the last result. Therefore you always need to specify the SetLastError=true in the DllImport-Attribute: [DllImport(“kernel32.dll”, SetLastError=true)] … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)