Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Assembly.GetEntryAssembly does not return proper path
mddheeraj
#1 Posted : Tuesday, May 11, 2021 11:20:21 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/11/2021(UTC)
Posts: 2
Location: United States of America

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
Remco
#2 Posted : Wednesday, May 12, 2021 1:39:04 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,368

Thanks: 829 times
Was thanked: 1108 time(s) in 1049 post(s)
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.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.028 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download