C# 无法加载文件或程序集';System.Net.Http,版本=2.2.29.0';
我正在使用VisualStudio2010构建VSTO Outlook外接程序。我没有安装Nuget软件包管理器。在Outlook中运行外接程序时,出现异常:C# 无法加载文件或程序集';System.Net.Http,版本=2.2.29.0';,c#,visual-studio-2010,.net-4.0,vsto,C#,Visual Studio 2010,.net 4.0,Vsto,我正在使用VisualStudio2010构建VSTO Outlook外接程序。我没有安装Nuget软件包管理器。在Outlook中运行外接程序时,出现异常: 无法加载文件或程序集'System.Net.Http,Version=2.2.29.0' 我只是从GitHub克隆了原始项目。当我使用VisualStudio在调试中运行它时,它工作得很好。但是,一旦我发布到setup.exe并安装,就会出现上述问题。已添加对System.Net.Http的引用 Outlook 2007版的我的app.c
无法加载文件或程序集'System.Net.Http,Version=2.2.29.0'
我只是从GitHub克隆了原始项目。当我使用VisualStudio在调试中运行它时,它工作得很好。但是,一旦我发布到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>
然后b同一解决方案中还有第三个项目(其业务逻辑由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
文件中的一部分
<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>