I have a solution that outputs data from a WCF service and reads it from a Dynamics 365 WebAPI.
The main project is a WCF service that is hosted in IIS. While debugging I use IIS Express.
I have a data layer project (dll) that has the CRM WebAPI Helper Classes
imported within the project.
When I launch the debugger (IISExpress), the data layer will use the WebAPI FileConfiguration
helper class to try and read configuration from it. This step fails because it tries to find a config file with a name C:\Program Files (x86)\IIS Express\iisexpress.exe.config
which doesn't exist. None of the project dlls exist in that directory.
I have created an IIS Virtual Directory and checked that the configuration points to the correct physical directory (where my solution is). I also tried incrementing the IISExpress port number by one so that it would create a new virtual directory.
My question is how to find the correct path for the data access dll regardless of the environment I'm in? The FileConfiguration
helper class uses Directory.GetCurrentDirectory()
and I'm not sure it it's always applicaple?
If I try to get the Assembly Path directly it will point to some temp directory that doesn't contain the config file.