Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using relative path in assemblyBindig/linkedConfiguration element

I'm trying to move assembly redirects from web.config into an external file. The reason for it is that I want to keep binding redirect in one place and use it on both debug and production configurations.

It sort of works, but I'm strugling with specifying relative paths.

<configuration>
   <!-- this works, but forces me to use the same path on dev and production machines -->
   <linkedConfiguration href="file://c:\data\web.runtime.config"/>

   <!-- none of those works -->
   <linkedConfiguration href="file://web.runtime.config"/>
   <linkedConfiguration href="file://..\web.runtime.config"/>
   <linkedConfiguration href="file://~/web.runtime.config"/>

</configuration>

I want to keep the web.runtime.config in the same folder as the rest of the web application. Is it possible to specify a relative path in linkedConfiguration element?

More info: I've tested it with IIS Express and ASP MVC application in VS 2015. When monitoring file accesses using SysInternals Process Monitor relative pathes seems to resolve to \\web.runtime.config (an invalid network path), while when using the absolute path no leading \\ is added.

like image 785
Martin Vobr Avatar asked Aug 20 '15 20:08

Martin Vobr


2 Answers

I found a way to specify relative path.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <linkedConfiguration href="file:./RuntimeConfiguration.xml"/>
</assemblyBinding>
like image 105
Oleg Yegorov Avatar answered Oct 24 '22 07:10

Oleg Yegorov


File web.runtime.config must be in bin dir.

And with href="file:web.runtime.config" it will be work

like image 24
Александр Пушкин Avatar answered Oct 24 '22 07:10

Александр Пушкин