如何解决避免在 app.config.net 框架中使用dependentAssembly
我正在寻找一种方法来避免需要在 app.config 文件中添加dependentAssembly。 实际的相关项目是一个应该添加到全局流程的库。无法修改全局进程(.net Framework)的app.config。
问题示例:
1.将 nuget 包 Application Insights 添加到我的控制台应用程序时 => 它不会在我的 app.config 中添加“dependentAssembly”部分。应用洞察库在进行测试时也能正常工作。
2.在添加 nuget 包 Serilog 和 Serilog Application Insights 时,它会在 app.config 文件中添加一个新的“dependentAssembly”部分。这个也很好用。
但是,在删除与应用程序洞察相关的“dependentAssembly”部分时,会出现以下错误:
无法加载文件或程序集“Microsoft.ApplicationInsights, 版本=2.12.0.21496,文化=中性, PublicKeyToken=31bf3856ad364e35' 或其依赖项之一。这 定位的程序集的清单定义与程序集不匹配 参考。 (来自 HRESULT 的异常:0x80131040)
==> 这不是唯一存在此类问题的 serilog 插件。 配置生成器还包括 app.config 中的“dependentAssembly”部分。
可以在此处找到 appconfig 示例:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.16.0.18277" newVersion="2.16.0.18277" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
错误消息通知它正在寻找 Version=2.12.0.21496 而我正在使用应用程序洞察的 2.16 版。这可以通过安装 v2.12.. 来解决,但我不想依赖它,因为它可能因每个服务器而异。
还有其他方法可以定义版本号吗?
先谢谢你!
亲切的问候, 库尔特
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。