在我的WCF代码中,我需要知道服务的物理位置,因此我使用HostingEnvironment.ApplicationPhysicalPath
。HostingEnvironment.ApplicationPhysicalPath和单元测试
但是由于托管环境不同,单元测试项目无法获得正常的价值。
你使用什么解决方案?
在我的WCF代码中,我需要知道服务的物理位置,因此我使用HostingEnvironment.ApplicationPhysicalPath
。HostingEnvironment.ApplicationPhysicalPath和单元测试
但是由于托管环境不同,单元测试项目无法获得正常的价值。
你使用什么解决方案?
这给你清单完整路径。不完全是你要求的,但目录路径应该是正确的。
System.Reflection.Assembly.GetAssembly(typeof(typeBeingTested)).Location
我用AppDomain.CurrentDomain.BaseDirectory
,它有点戏法。在单元测试中,我得到了D:\ MyProjects \ MyService.Tests \ bin \ Debug \,所以我必须在单元测试项目中创建一些后生成事件注意位置差异。
它不起作用,我的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
基于你提到System.Web.Hosting.HostingEnvironment的问题我认为问题是单元测试没有运行IIS ... – ErnieL 2012-08-09 13:56:55