6

I have a ASP.NET Core 1.0 MVC app in solution X and I have some common projects (.net 4.5.2 class libs) in solution Y.

I want to reference the projects in solution Y from my app, when I do so via add reference -> Browse .. I get:

.NET Core projects only support referencing .NET framework assemblies in this release. To reference other assemblies, they need to be included in a NuGet package and reference that package. 

I then created a nuget package of those projects, added the folder that contains the nuget packages as a repo source and loaded the projects. This adds the projects successfully to my project.json, but 'nothing' else actually happens, I still can't use the code in my app.

Now ASP.NET Core is past its beta status, what is the official way of dealing with this?

3
  • Are you targeting full .NET Framework or .NET Core? What's your project.json? Commented Jun 29, 2016 at 18:48
  • I'm using the full .NET framework (net452) Commented Jun 30, 2016 at 5:53
  • Is the NuGet method the way to go for the future, or just temporary until they sort things out? we're using NancyFX right now, I was thinking about trying .NET Core but this is such a major turn off, I'm not sure it's work the effort Commented Dec 24, 2016 at 23:22

2 Answers 2

0

Many people have struggled with this issue and there is a long running thread on GitHub about it. Even the people using the latest RC3 build are reporting the same problem that you are having.

The only way I've been able to reference class library projects in an ASP.NET Core web application is to create both the web application and the class library projects in Visual Studio 2015 Update 2. And they all have to target .NET Framework 4.6.1.

I had to copy the code from my old class library projects to the new ones. But in the end I think I saved myself time by not having to mess with all the workarounds that don't seem to work for a lot of people.

Sign up to request clarification or add additional context in comments.

7 Comments

Ok, it's a (not so great) workaround. However, it would be nice if you could analyze it further by doing a DIFF between the old project and a the new to narrow it to the specific part or parts of the project that actually need to change to fix the problem. At the very least, post the DIFF (or a link to it) here so others can try to work it out.
I can't go higher than .net 4.5.2. because I also have a Azure Cloud Service project (that references the common projects) that limits the version to 4.5
I tried changing the projects and webapp to 461 (and I created the projects in an update 3 solution but that didn't change anything for me...
@user2713516 - I haven't installed update 3 because my stuff is working and I don't want to take the chance of anything breaking. I've been struggling with this issue for 10 months and none of the workarounds I read about worked for me. Since update 2 came out at the same time as RC2, I'm thinking they go together.
@NightOwl888 - Since RC2 was a major change and RC2 required you to install update 2, I'm thinking there were major changes that go far beyond the project files. For that reason I never considered trying to figure out why it works and I don't intend to. I've wasted so much time on this issue, I was happy just to have something working.
|
0

Now, in 2025 with ASP.NET Core at version 9, this is still a common issue and the only way to consume those ".net 4.5.2 class libs" from ASP.NET Core is to update them to target .NET Standard 1.3.

However, this will only work if those libs only have dependencies upon libraries/packages targetting .NET Standard 1.3 or earlier.

For details on .NET Standard version and compatibility with various .NET frameworks/versions see the offical .NET Standard documentation.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.