【发布时间】:2018-01-04 20:40:23
【问题描述】:
我在此有单元测试项目,我正在使用 AspNetDevelopmentServer 属性在本地测试我的 wcf 服务。当我像这样给出硬编码的参数时,它工作正常
[AspNetDevelopmentServer("Test",@"C:\\Users\\LocalSourcePath")]
当我尝试通过变量(动态)传递这个参数时,比如
string path = @Directory.GetParent((Directory.GetParent(Path.GetDirectoryName((new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).LocalPath))).Parent.FullName).FullName+"\\Publish";
[AspNetDevelopmentServer("Test",path )]
它会抛出这样的错误:
"属性参数必须是常量表达式,typeof 属性参数类型的表达式或数组创建表达式 "
还有其他方法可以将动态值传递给属性吗?提前谢谢。
【问题讨论】:
标签: c# asp.net unit-testing wcf aspnet-development-server