0

Before 1 year I create app on asp.NET Private API, Now I try to start but Every time when I try to see my data on JSON format the project give me error.

Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0012: The type 'Dictionary<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Source Error:

View/Web.config

 <?xml version="1.0"?>

<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
        <add namespace="Private_API" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>

  <system.webServer>
    <handlers>
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
  </system.webServer>

  <system.web>
    <compilation>
      <assemblies>
        <add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>
  </system.web>
</configuration>

Can you provide instructions on how to fix the error or directly instructions for the problem ?

Pizhev Racing
  • 466
  • 1
  • 6
  • 23
  • _"You must add a reference to assembly 'System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'."_ It says so in the message. I am just wondering: How can it _not_ be referenced? Did you check if it _is_? And which version? Did you change Framework versions or something like that? – Fildor Sep 09 '19 at 12:46
  • I not change anything – Pizhev Racing Sep 09 '19 at 12:50
  • What do you mean by _"when I try to see my data on JSON format"_? What request do you issue to your application and how? Anyway read [ask] and share your research. See for example [Assembly Not Referenced compilation error in foreach loop in Razor view](https://stackoverflow.com/questions/29575216/), show your `Views/Web.config`. – CodeCaster Sep 09 '19 at 12:51
  • I have only this assembly I try to add refference like assembly but I cant find: Assembly System.Collections.Immutable C:\Users\admin\Desktop\Private-API-git-master\Private-API-git-master\packages\System.Collections.Immutable.1.1.37\lib\dotnet\System.Collections.Immutable.dll – Pizhev Racing Sep 09 '19 at 12:54
  • I update my web.config but I still cant find solution.. – Pizhev Racing Sep 09 '19 at 12:58
  • See also [Visual Studio asks me to reference a nonexistent assembly](https://stackoverflow.com/questions/27976099/visual-studio-asks-me-to-reference-a-nonexistent-assembly). Is your project targeting the .NET Framework and MVC 5, or did you try to convert stuff to .NET Core and ASP.NET Core? – CodeCaster Sep 09 '19 at 14:30

0 Answers0