webservice 引用外部资源,默认的查找路径

xiven 2010-12-15 06:47:02

比如在webservice 中引用一个外部DLL
    [DllImport("XXX.dll")]
public static extern int text(string value);



DllImport("XXX.dll") ,他先后会从哪些路径中去查找:XXX.dll, 当然并没有在 web.config 设置查找路径
...全文
91 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiven 2010-12-16
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 findcaiyzh 的回复:]
顺序应该是这样的

1. The directory from which the application loaded.
2. The current directory.
3. The system directory. Use the GetSystemDirectory function to get the path of this directory.
4. The 16-b……
[/Quote]

谢谢你的回复,可是我这里是webservice的引用外部非托管资源,,貌似查找路径不是这样的。 目前我知道的是他会在 C:\WINDOWS\system32\inetsrv 这个IIS 的安装路径去查找,,可是不可能吧所有的资源放到这里吧··
xiven 2010-12-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wuyq11 的回复:]
放在和执行程序同个目录下
把当前目录的地址传给dll,用Server.MapPath把当前目录换成绝对目录
[/Quote]


我的DLL 是静态引用了,怎么能把Server.MapPath的值设置给一个 常量的 [DllImport("XXX.dll")] ??
宝_爸 2010-12-16
  • 打赏
  • 举报
回复
但是要注意的是web service的执行程序所在的路径不是bin
而是C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
宝_爸 2010-12-16
  • 打赏
  • 举报
回复
顺序应该是这样的

1. The directory from which the application loaded.
2. The current directory.
3. The system directory. Use the GetSystemDirectory function to get the path of this directory.
4. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.

参考
http://msdn.microsoft.com/en-US/library/ms682586.aspx
wuyq11 2010-12-15
  • 打赏
  • 举报
回复
放在和执行程序同个目录下
把当前目录的地址传给dll,用Server.MapPath把当前目录换成绝对目录
pcqpzq 2010-12-15
  • 打赏
  • 举报
回复
webservice本地路径(包括bin目录) ;系统环境变量path定义的路径

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧