2012-08-07 51 views

回答

1

这给你清单完整路径。不完全是你要求的,但目录路径应该是正确的。

System.Reflection.Assembly.GetAssembly(typeof(typeBeingTested)).Location 
+0

它不起作用,我的WCF托管在IIS中,因此我得到's =“c:\\ WINDOWS \\ Microsoft.NET \\ Framework \\ v4.0.30319 \\ Temporary ASP.NET Files \\ root \ \ 134d68ef \\ ccb77aaa \\程序集\\ dl3 \\ dba7079a \\ 0d7d9d95_6675cd01 \\ MyServices.DLL“ – hardywang 2012-08-08 13:07:40

+0

基于你提到System.Web.Hosting.HostingEnvironment的问题我认为问题是单元测试没有运行IIS ... – ErnieL 2012-08-09 13:56:55

0

我用AppDomain.CurrentDomain.BaseDirectory,它有点戏法。在单元测试中,我得到了D:\ MyProjects \ MyService.Tests \ bin \ Debug \,所以我必须在单元测试项目中创建一些后生成事件注意位置差异。