在AssemblyBindig/linkedConfiguration元素中使用相对路径 [英] Using relative path in assemblyBindig/linkedConfiguration element
问题描述
我正在尝试将程序集重定向从web.config
移至外部文件.原因是我想将绑定重定向保持在一个地方,并在调试和生产配置中都使用它.
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>
我想将web.runtime.config
与Web应用程序的其余部分保留在同一文件夹中.是否可以在linkedConfiguration
元素中指定相对路径?
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?
更多信息:
我已经在VS 2015中使用IIS Express和ASP MVC应用程序对其进行了测试.使用SysInternals Process Monitor监视文件访问时,相对路径似乎解析为\\web.runtime.config
(无效的网络路径),而使用绝对路径时则无前导
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.
推荐答案
我找到了一种指定相对路径的方法.
I found a way to specify relative path.
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<linkedConfiguration href="file:./RuntimeConfiguration.xml"/>
</assemblyBinding>
这篇关于在AssemblyBindig/linkedConfiguration元素中使用相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!