ExtractAssociatedIcon does not allow UNC paths for the simple reason that it explicitly forbids them: https://github.com/dotnet/corefx/blob/24ecf9184fee4cd26446f8d669d8505ac6c5108a/src/System.Drawing.Common/src/System/Drawing/Icon.Windows.cs#L181-L184
This is a completely arbitrary restriction since the underlying native call ExtractAssociatedIcon does not have any such restriction, and it causes software to fail when running from a network location for apparently no reason whatsoever.
cc @safern @maryamariyan
I see that in the v2.0 copy and I don't have source history handy that goes back that far. Wild guess, this was in 1.0 and they weren't sure that the security demand they were going to make would work on UNC?
I can't see any reason to not remove it, if it works. @poizan42 do you want to offer a PR? (And test perhaps -- you can use \\{Environment.MachineName}\X$\foo\bar syntax perhaps?
That's just an ancient artifact. Partial trust is dead, so that check can be removed.
@poizan42 would you like to offer a PR?If so let me know if you need help with build/fix/test workflow you could start from https://github.com/dotnet/corefx/wiki/New-contributor-Docs#contributing-guide
If you're not interested I could try to fix it for you.
@danmosemsft @karelz @safern @maryamariyan if you agree I would update also guide https://docs.microsoft.com/en-us/dotnet/api/system.drawing.icon.extractassociatedicon?view=netcore-2.2#exceptions if we'll merge.
Well, I can easily make a PR for just removing the lines :D - but for any tests I need to set up a develop environment, and I'm currently in the middle of moving apartments, so I probably won't have time for that in the next two weeks.
Most helpful comment
@danmosemsft @karelz @safern @maryamariyan if you agree I would update also guide https://docs.microsoft.com/en-us/dotnet/api/system.drawing.icon.extractassociatedicon?view=netcore-2.2#exceptions if we'll merge.