比如在webservice  中引用一个外部DLL
    [DllImport("XXX.dll")]
    public static extern int text(string value);
DllImport("XXX.dll") ,他先后会从哪些路径中去查找:XXX.dll, 当然并没有在  web.config 设置查找路径

解决方案 »

  1.   

    webservice本地路径(包括bin目录) ;系统环境变量path定义的路径
      

  2.   

    放在和执行程序同个目录下
    把当前目录的地址传给dll,用Server.MapPath把当前目录换成绝对目录
      

  3.   

    顺序应该是这样的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
      

  4.   

    但是要注意的是web service的执行程序所在的路径不是bin
    而是C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
      

  5.   

    我的DLL 是静态引用了,怎么能把Server.MapPath的值设置给一个 常量的 [DllImport("XXX.dll")] ??  
      

  6.   


    谢谢你的回复,可是我这里是webservice的引用外部非托管资源,,貌似查找路径不是这样的。 目前我知道的是他会在  C:\WINDOWS\system32\inetsrv 这个IIS 的安装路径去查找,,可是不可能吧所有的资源放到这里吧··