我的网络应用程序位于'D:\ WebApp文件夹'并且'D:\ Bin'文件夹中有一个dll,我想使用相对路径使用ninject bind the dll而不是使用绝对路径'D:\ Bin'直接,因为绝对路径可能在某处改变。
代码如下:
string path="how to get the path";
kernel.Bind(x => x.FromAssembliesInPath("path")
.SelectAllClasses()
.BindDefaultInterface());
我如何在代码中获得路径?
答案 0 :(得分:1)
路径可以是相对于工作目录的路径,例如“.. \ BIN \ the.dll”。确保路径位于应用程序的探测路径配置中。