简体   繁体   中英

WCF Service hosted on IIS running in context of physical directory

I've got a little problem with my WCF service running under the IIS. My service uses third party libraries. This lib for initialization needs the configuration file that contains paths to the query files. Running under the IIS this lib cannot deal with the relative paths of the query files ie: .\\Config\\Lib_query.txt etc. From my understanding reason is that the service is running under do w3wp process. There is no problem with running this on self-host or even in unit tests.

Is there any way of telling IIS to run under different context? Using AppDomain. CurrentDomain. BaseDirectory etc. isn't an option because I have no power inside those libs. So far I was using the fixed path, but we're moving to distributed environment and not replacing path in config path will be a huge convenience.

Assuming the library uses a relative path, you can just chance the directory to the directory your application is in.

See Defining a working directory for executing a program (C#) . You can do so in the application start of your global.asax.

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