我有单元测试项目,我正在使用 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表达式或数组创建表达式”
有没有其他方法可以将动态值传递给属性?谢谢是提前。