如何在Mac机器的Mvc Project中添加程序集?

时间:2023-01-27 10:20:50

Application startup exception: System.IO.FileLoadException: Could not load file or assembly 'testapp, Culture=neutral, PublicKeyToken=null' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500

应用程序启动异常:System.IO.FileLoadException:无法加载文件或程序集'testapp,Culture = neutral,PublicKeyToken = null'或其依赖项之一。一般异常(HRESULT异常:0x80131500

File name: 'testapp, Culture=neutral, PublicKeyToken=null' ---> Microsoft.Dnx.Compilation.CSharp.RoslynCompilationException: /Users/brilliomac/Desktop/testapp/Controllers/HomeController.cs(26,48): DNXCore,Version=v5.0 error CS1061: 'HttpContent' does not contain a definition for 'ReadAsAsync' and no extension method 'ReadAsAsync' accepting a first argument of type 'HttpContent' could be found (are you missing a using directive or an assembly reference?)

文件名:'testapp,Culture = neutral,PublicKeyToken = null'---> Microsoft.Dnx.Compilation.CSharp.RoslynCompilationException:/Users/brilliomac/Desktop/testapp/Controllers/HomeController.cs(26,48):DNXCore,版本= v5.0错误CS1061:'HttpContent'不包含'ReadAsAsync'的定义,并且没有扩展方法'ReadAsAsync'接受类型为'HttpContent'的第一个参数'(您是否缺少using指令或程序集引用) ?)

I got solution from this link I tried to add assembly to web.config still I am getting same error

我从这个链接获得解决方案我试图将程序集添加到web.config仍然我得到相同的错误

My web.config file

我的web.config文件

<?xml version="1.0" encoding="utf-8"?>
 <configuration>
  <system.webServer>
   <handlers>
     <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
   </handlers>
   <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
  </system.webServer>
  <system.web> 
   <compilation debug="true" targetFramework="4.0">
     <assemblies>
         <add assembly="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
     </assemblies>
   </compilation>
  </system.web> 
</configuration>

tried this also

也试过这个

<system.webServer>
   <handlers>
     <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
   </handlers>
   <assemblies>
         <add assembly="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   </assemblies>
   <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
</system.webServer>

1 个解决方案

#1


0  

Can you confirm you are using Mac?

你能确认你使用的是Mac吗?

I would use the command dnu install Microsoft.AspNet.WebApi.Client and then attempt to recompile. This should hopefully resolve your issue.

我会使用命令dnu install Microsoft.AspNet.WebApi.Client然后尝试重新编译。这应该有希望解决您的问题。

This should be the package you require.

这应该是您需要的包裹。

#1


0  

Can you confirm you are using Mac?

你能确认你使用的是Mac吗?

I would use the command dnu install Microsoft.AspNet.WebApi.Client and then attempt to recompile. This should hopefully resolve your issue.

我会使用命令dnu install Microsoft.AspNet.WebApi.Client然后尝试重新编译。这应该有希望解决您的问题。

This should be the package you require.

这应该是您需要的包裹。