AppDomain.CurrentDomain.BaseDirectory returns different values in Rider and VS Studio 2015

572 Views Asked by At

I have a project where I use System.AppDomain.CurrentDomain.BaseDirectory as part of the path to a json file I need to load. The value of the property in Rider is

...\MyProject\MyProject.Tests\bin

However in VS Studio 2015 the value is

...\MyProject\MyProject.Tests\bin\Debug

In both cases the name of the run configuration is Debug so I would have expected the return value to be the same.

According to this answer the property returns the base directory that the assembly resolver uses to probe for assemblies. Is it possible to change that base directory in Rider? Or is there a better method to load the json file that will get around this problem?

I am running Rider version 2017.1.1 on Windows 10.

If I run the code in a console project it works perfect, but if the project type is a library class project or a NUnit Test Project System.AppDomain.CurrentDomain.BaseDirectory references \MyProject\MyProject.Tests\bin instead of \MyProject\MyProject.Tests\bin\Debug

1

There are 1 best solutions below

1
On

Could add additional info about your OS and project type. I check your code on simple console application in Rider. It worked correctly. screen