Daily Usage Issues

Assembly.GetEntryAssembly does not return proper path

Started by mddheeraj on 2,211 views

Hi,

We have written some BVT's which use the Assembly.GetEntryAssembly().Location to get the appsettings.json file.
If we run the test using regular Visual Studio Test explorer the Assembly.GetEntryAssembly().Location returns properly but when NCrunch runs its, Assembly.GetEntryAssembly().Location returns the appdata roaming location, which does not have the required files.

Is there a way to change the settings of NCrunch to change this behavior?

Thank You,
Dheeraj
Hi Dheeraj,

Assembly.GetEntryAssembly() will always return the location of the .EXE as executed by the operation system. In the context of a test runner, this will therefore return the location of the tool you are using to run the test.

Some versions of VS Test may copy their runner EXEs to your working directory, and as such you might get by like this with VSTest, but it won't work for other runners. We cannot support such a setup under NCrunch. I recommend using a different API to find the location of your code, such as GetType().Assembly.Location instead.

Post a reply

Log in to reply.