dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.97k stars 4.66k forks source link

You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral ?? #6010

Closed DevZ1 closed 4 years ago

DevZ1 commented 8 years ago

Hi Devs,

first of all I want to to say that I really like RC1 release, but didn't expect the MS team to radically change everything in RC2? 👎 Why call it RC while you changed practically everything in the RC2 release? My whole project doesn't work and i'm spending days to convert everything to RC2 and my project is still not working. I want to host everything under IIS, so cross platform does not interest me and want to use also .NET Framework libraries. One of them is ReflectSoftware.Insight for debugging and logging purposes. I've added the package through Nuget, but when I add _ri.SendDebug("test"); to my code, I get the following compiler error:

The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. FFSNXG..NETCoreApp,Version=v1.0

How can I make this work, so I can use some of our .NET Framework 4.xx libs in my project? How can i add this lib so libs such as SendGrid & ReflectInsight works? Thanks very much for your help!

My Project file is:

`{ "userSecretsId": "aspnet-FFSNXG-xxxxxxxxxx",

"dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0-rc2-3002702", "type": "platform" }, "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-final", "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final", "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final", "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final", "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final", "Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview1-final", "type": "build" }, "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final", "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final", "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final", "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final", "Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-preview1-final", "type": "build" }, "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final", "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc2-final", "Microsoft.Extensions.Logging": "1.0.0-rc2-final", "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final", "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final", "Microsoft.VisualStudio.Web.CodeGeneration.Tools": { "version": "1.0.0-preview1-final", "type": "build" }, "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": { "version": "1.0.0-preview1-final", "type": "build" }, "NXGDAL": "1.0.0-*", "Microsoft.Framework.Runtime.Abstractions": "1.0.0-beta5", "Microsoft.AspNetCore.Session": "1.0.0-rc2-final", "ReflectSoftware.Insight": "5.6.0", "Sendgrid": "6.3.4" },

"tools": { "Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview1-final", "imports": "portable-net45+win8+dnxcore50" }, "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-preview1-final", "imports": "portable-net45+win8+dnxcore50" }, "Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-preview1-final", "imports": [ "portable-net45+win8+dnxcore50", "portable-net45+win8" ] }, "Microsoft.Extensions.SecretManager.Tools": { "version": "1.0.0-preview1-final", "imports": "portable-net45+win8+dnxcore50" }, "Microsoft.VisualStudio.Web.CodeGeneration.Tools": { "version": "1.0.0-preview1-final", "imports": [ "portable-net45+win8+dnxcore50", "portable-net45+win8" ] } },

"frameworks": { "netcoreapp1.0": { "imports": [ "dotnet5.6", "dnxcore50", "portable-net45+win8", "net452" ] } },

"buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true },

"runtimeOptions": { "gcServer": true },

"publishOptions": { "include": [ "wwwroot", "Views", "appsettings.json", "web.config" ] },

"scripts": { "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ], "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] } } `

myungjoo commented 8 years ago

It looks like as if you didn't update the managed dll files of coreclr while you have updated other native executables and shared libraries of coreclr. I often see such error if I didn't match coreclr managed dlls (in Linux, there are two .dll from coreclr) with native executables (in Linux, they are .so and corerun, and other utilities).

Or.. maybe you have built your *.cs files based on non reference dlls including mscorlib.dll?

seanshpark commented 8 years ago

How can I make this work, so I can use some of our .NET Framework 4.xx libs in my project?

Just curious, can this be possible with coreclr? (I'm actually newbie in .NET)

shahid-pk commented 8 years ago

@seanshpark this was never possible even with rc-1, but i think his question is about using .net framework full assemblies with asp.net core for which it is possible because asp.net core also runs on .net framework full. Although you can create libraries now after the introduction to netstandard that can be used from .net framework full as well as .net core but that came possible only after rc2 release (if we exclude PCL assemblies :smile:).

@DevZ1 your problem from your project.json is that your are targeting .net core and then using some .net framework full libraries , you need to target .net framework full and since this question is related to asp.net core the better place to ask this question will be aspnet/home github repository. You can also read the migrations guides from rc1 to rc2 in the docs https://docs.asp.net/en/latest/

brentarias commented 8 years ago

I'm having the same problem. I have an ASP.NET Core project that I created with Visual Studio 2015. I added a single NuGet package that is allegedly compatible with RC2, but the result was this "must add mscorlib" message. Unfortunately, intellisense actions will not resolve this for me...and I don't know how to manually add mscorlib to the project.json.

Here is a separate git issue I posted regarding this problem. It contains additional information.

The NuGet package I included is called "React.AspNet".

shahid-pk commented 8 years ago

@brentarias your issue is the same , you are trying to use an assembly which was compiled for .net 4.5 (in this case React.AspNet), this can not be done , assembly compiled for .net 4.5 cannot be used in .net core.

If React.AspNet instead targets netstandard 1.1 then it can be used in .net 4.5 and in .net core both.

Daniel15 commented 8 years ago

If React.AspNet instead targets netstandard 1.1 then it can be used in .net 4.5 and in .net core both.

I'm the developer of React.AspNet (ReactJS.NET). It uses JavaScriptEngineSwitcher which uses ClearScript. Neither of those libraries support .NET Core yet. I'm waiting for JavaScriptEngineSwitcher to support .NET Core before supporting it in ReactJS.NET. I read somewhere that someone got VroomJs working in .NET Core, so I'm considering dropping JavaScriptEngineSwitcher for the .NET Core build and just using VroomJs directly.

joperezr commented 4 years ago

This issue was logged a long time ago and since then a lot of changes have gone in to the generation of shims and facades included in the frameworks so that this problem wouldn't happen any longer so I'm closing this for now. Feel free to reopen if anybody else starts hitting this.