c# - 使用 DTE,阅读 .NET 标准项目,配置管理器属性属性值抛出
问题描述
我的项目是 Visual Studio 2019 中的 VSIX 项目。
我正在使用 DTE2 读取每个构建配置,然后检查 NoWarn 属性的值。
对于诸如 WPF 项目之类的 .NET 项目,以下代码可以完美运行。
对于 .NET Standard 项目,它在尝试读取 nownarnProperty.Value 时崩溃。
foreach (Configuration configuration in project.ConfigurationManager) {
Properties configurationProperties = configuration.Properties;
Property nowarnProperty = configurationProperties.Item("NoWarn");
var value = nowarnProperty.Value;
}
.NET Standard 项目在尝试读取值时抛出:
StackTrace - nowarnProperty.Value 'nowarnProperty.Value' 引发了类型为 'System.Runtime.InteropServices.COMException' 对象 {System.Runtime.InteropServices.COMException} 的异常
问题
Microsoft 是否有不同的方法来读取 .NET 项目和 .NET 标准项目之间的值?
我必须使用一个特殊的库来读取上述属性
值吗?
非常感谢您,
卡尔
解决方案
推荐阅读
- c - 如何使用集成的 Visual Studio Code 终端从标准输入读取数据?
- google-apps-script - 如何访问 gmail 插件标题菜单?
- neural-network - 激活函数如何工作?
- javascript - TypeError: ctx.onCreditChange 不是函数角度
- java - 正则表达式允许数字之间有空格或在第一个之前没有空格
- javascript - 将自定义字符串转换为 Angular 日期
- grails - Grails 3.3.11 集成测试 - 回滚事务
- jquery - 引导程序 | JQuery:如何在表单提交单击期间对字段启用“必需”验证?
- vba - SAP GUI 脚本记录仅捕获部分动作
- java - 为什么我的 Jsoup 代码没有返回正确的元素?