The unit test in Visual Studio has a bug:
AppDomain.CurrentDomain.BaseDirectory always returns the installtion directory of the visual studio 2008 instead of the 'Out' directory.
So if your code have to access data files deployed to the 'Out' directory using relative path, error occurs.
A workaround is:
AppDomain.CurrentDomain.BaseDirectory always returns the installtion directory of the visual studio 2008 instead of the 'Out' directory.
So if your code have to access data files deployed to the 'Out' directory using relative path, error occurs.
A workaround is:
public static GetApplicationBaseDirectory {
if (AppDomain.CurrentDomain.FriendlyName.StartsWith("UnitTestAdapterDomain_")) {
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}
return AppDomain.CurrentDomain.BaseDirectory;
}
if (AppDomain.CurrentDomain.FriendlyName.StartsWith("UnitTestAdapterDomain_")) {
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}
return AppDomain.CurrentDomain.BaseDirectory;
}