Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Could we change assembly.Location to new Uri(assembly.CodeBase).LocalPath? #6

Closed
up2pixy opened this issue Dec 8, 2016 · 1 comment

Comments

@up2pixy
Copy link
Contributor

up2pixy commented Dec 8, 2016

In ResourceStaticAnalysisConfigMacroHandler, the LoadConfigMacros() method looks up "ResourceStaticAnalysisConfigMacros.xml" from the directory of its assembly.Location. This is ok when the handled is invoked from local. But when the macro handler is used in web environment, the CodeBase of the assembly and the physical location of the app instance on IIS is different...

E,g.
The Location is
C:\Users\mchen\AppData\Local\Temp\Temporary ASP.NET Files\root\cdecd0db\71a84541\assembly\dl3\389eb5b0\00c17472_911ad201\Microsoft.ResourceStaticAnalysis.Configuration.dll

The CodeBase is
File://D:/Git/QS_IRIS/Iris/src/Iris.Web/bin/Microsoft.ResourceStaticAnalysis.Configuration.dll

As a workaround, in order to make the macro handler find the xml correctly, I need to copy the macro xml file from bin folder to the physical folder where the assembly is loaded from.

If we can change the line 247 in file ResourceStaticAnalysisConfigMacroHandler.cs
from

String pathToFile = Path.Combine(Path.GetDirectoryName(assembly.Location), macroDefinitionFile);

to

String pathToFile = Path.Combine(Path.GetDirectoryName(new Uri(assembly.CodeBase).LocalPath), macroDefinitionFile);

It will resolve the issue.

@up2pixy up2pixy changed the title Could we change assembly.Location to new Uri(assembly.CodeBase).LocalPath Could we change assembly.Location to new Uri(assembly.CodeBase).LocalPath? Dec 8, 2016
@up2pixy
Copy link
Contributor Author

up2pixy commented Dec 9, 2016

This is fixed and merged into Master

@up2pixy up2pixy closed this as completed Dec 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant