gpt4 book ai didi

c# - 无法加载文件或程序集 'System.Net.Http, Version=2.2.29.0'

转载 作者:行者123 更新时间:2023-11-30 23:07:12 25 4
gpt4 key购买 nike

我正在开发使用 Visual Studio 2010 构建的 VSTO Outlook 加载项。我没有安装 Nuget 包管理器。当我在 Outlook 中运行加载项时出现异常:

无法加载文件或程序集“System.Net.Http,Version=2.2.29.0”

我只是从 GitHub 上克隆了原始项目。当我使用 Visual Studio 在 Debug 中运行它时,它工作正常。但是,一旦我发布到 setup.exe 并安装,我就会遇到上述问题。已添加对 System.Net.Http 的引用。

我的 Outlook 2007 版 app.config 文件是:

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Outlook2007.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.2.29.0" newVersion="2.2.29.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><userSettings>
<PluginOutlook2007.Properties.Settings>
<setting name="TokenSettingNeed" serializeAs="String">
<value>else imported dll settings don t work</value>
</setting>
</PluginOutlook2007.Properties.Settings>
</userSettings>
</configuration>

在同一个解决方案中,还有第二个针对 Outlook 2010 的项目。app.comfig 如下:

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="PluginOutlook2010.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.2.29.0" newVersion="2.2.29.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<userSettings>
<PluginOutlook2010.Properties.Settings>
<setting name="testval" serializeAs="String">
<value>34</value>
</setting>
</PluginOutlook2010.Properties.Settings>
</userSettings>
</configuration>

然后在同一解决方案中有第三个项目(它具有 2007 年和 2010 年项目与下面的 app.config 共享的业务逻辑。System.Net.Http 命名空间实际被第三个项目使用:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="PluginOutlookCommon.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
// some stuff here
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /></startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.29.0" newVersion="2.2.29.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

最佳答案

我设法通过注释掉

解决了这个问题
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.29.0" newVersion="2.2.29.0" />
</dependentAssembly>
</assemblyBinding>

app.config 文件中的一部分。

关于c# - 无法加载文件或程序集 'System.Net.Http, Version=2.2.29.0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47523932/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com