문제

I have email templates (and emailer) in separate class library project. I am getting path to views (copy to ouput directory = true) like this:

var basePath = AppDomain.CurrentDomain.RelativeSearchPath;
var path = Path.Combine(basePath, "Views", viewname + ".cshtml");

When I try to run this code in unit test project basePath is null.But it shouldn't be null!!

Who can explain me -

  1. why basepath is null?
  2. how to fix it?
도움이 되었습니까?

해결책

As per MSDN:

Private assemblies are deployed in the same directory structure as the application. If the path specified by the RelativeSearchPath property is not under AppDomainSetup.ApplicationBase, it is ignored.

This property returns the value set using AppDomainSetup.PrivateBinPath.

You should set AppDomainSetup.PrivateBinPath first.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top