简体   繁体   中英

iis7 hosted wcf service : avoid placing dll in system32 folder

I have a wcf service referencing a dll. Only way it works is by placing the dll in %windir%/system32 folder.

Things I have tried

  • tried switching between iis express, development server and iis (but this is irrelevant)
  • placing the dll in the bin folder and/or other application folders
  • trying to use the "regsvr32" util but the dll is not a com dll so it does not work.(no ddl entry point)
  • It is not a .NET dll so I don't think GAC can be manipulated to work with this
  • played with the system path variable without any success

What I actually want
A simpler method to access the dlls so I do not have to place the dll in system32 but contain it in an application folder and access it from there.

What am I missing?


EDIT: I did find this post interesting and similar but again, it also uses the system32 method which is not the way to go.

If this is a win32 native library, you can "preload" it from a known location using pinvoked LoadLibrary passing a full path of your library as a parameter, somewhere early in your processing pipeline.

When any method from the library decorated with DllImport is called, the runtime will try to load the library (and would fall because the dll cannot be found) but since you preloaded it eariler, loading will succeed (loader checks the library file name, doesn't pay any attention to the directory the library is loaded from).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM