I have created a class library for a context menu in VB.NET using SharpShell.
Within it, I utilize System.Drawing components like images to handle icons for displaying in the context menu.
However, after testing, I found that after approximately 72 uses (around 72 right-clicks), the menu crashes (the context menu turns black and narrow, with no text or icons, just pure black or white).
During debugging, the following message appears at the time of the crash, and after the crash, classes under System.Drawing such as Image, Icon, etc., that were working normally, become nothing (losing the System.Drawing reference):
“explorer.exe” (CLR v4.0.30319: DefaultDomain): Loaded ‘C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Drawing.resourcesv4.0_4.0.0.0_zh-Hans_b03f5f7f11d50a3aSystem.Drawing.resources.dll’. Module was built without symbols.
Context Menu On Desktop
Crash after 72 times, Class Bitmap become NOTHING
I have tried using asynchronous, synchronous, or caching methods to load icons, but none of them have changed the crashing result.
At this point, only restarting Explorer restores the normal functionality. But after another 72 uses, it crashes again. (It seems C# also exhibits this behavior.)
What is the cause of this? Is it a bug in System.Drawing itself, or a limitation of the library or Explorer itself?
A crucial point: If icons are not used, meaning System.Drawing is not utilized, Explorer does not crash.
Thank you!
Vincent W is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.