Using relative path in assemblyBindig/linkedConfiguration element

白昼怎懂夜的黑 提交于 2019-12-10 03:59:27

问题


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.


回答1:


I found a way to specify relative path.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <linkedConfiguration href="file:./RuntimeConfiguration.xml"/>
</assemblyBinding>


来源:https://stackoverflow.com/questions/32128049/using-relative-path-in-assemblybindig-linkedconfiguration-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!