user458348
user458348

Reputation:

Assembly.Location doesn't returns dll location

I'm looking for a way to return my assembly location at runtime, I can't use Assembly.Location because it returns the shadow-copied assembly's path when running under NUnit.

Upvotes: 0

Views: 83

Answers (1)

user2259161
user2259161

Reputation:

Use CodeBase property instead, it return the original dll location rather than the shadow copied dll location.

For example:

Assembly assembly = GetType().Assembly;    
Uri codeBaseUri = new Uri(assembly.CodeBase);
string path = codeBaseUri.LocalPath;

Upvotes: 3

Related Questions