I have C# code that is trying to get the LocalPath
for a executing assembly using the following line of code:
Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
This piece of code performs fine for all the variety of paths. It started to fail giving the right AbsolutePath
and Localpath
because the executing assembly path contained a # in it.
Assembly.GetExecutingAssembly().CodeBase
gives "C:\c#\ExcelAddin1.1.0\GSRExcelPlugin\bin\Debug\Common.dll"
But new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath gives "C:\c" while it should have given "C:\c#\ExcelAddin1.1.0\GSRExcelPlugin\bin\Debug\".
Is there something that I need to handle or is there something wrong the way Uri class is used?
If this is a .net framework issue, how should I report this issue to Microsoft?