Skip to content

Cannot use 4.5.1 Class Library in ASP.NET 5 beta 7 #961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
seanmerron opened this issue Oct 1, 2015 · 3 comments
Closed

Cannot use 4.5.1 Class Library in ASP.NET 5 beta 7 #961

seanmerron opened this issue Oct 1, 2015 · 3 comments

Comments

@seanmerron
Copy link

Hello,

I created a new ASP.NET 5 Beta 7 web project and then add a dll reference to a .NET 4.5.1 Class Library (Non-DNX). Intellisense let's me use the library but at compile time I get "The type or namespace name 'MyLibrary' could not be found (are you missing a using directive or an assembly reference?)."

I thought this feature was available but appears to be not be working. On a related note, will we ever be able to "Add Existing Project" to src for a .NET 4.5.1 Class Library csproj and add reference that way for code shared between multiple apps? Or will the dll/nuget reference be the only support?

Thanks for all of the great work you all are doing!

@yukozh
Copy link
Contributor

yukozh commented Oct 1, 2015

What's in your project.json?

Maybe, you can have a try to remove the dnxcore50 from the frameworks in your project.json.

image

The net451 or dnx451 libraries cannot be run on dnxcore50 clr.

@seanmerron
Copy link
Author

Doh! That makes complete sense and did the trick! Once I removed core, it compiled fine. I guess the little intellisense warning icons for non-core code don't come up in these cases (Maybe a future improvement).

I also tested leaving dnxcore50 in project.json and then wrapping the usage of the 4.5.1 library code in #if DNX451 which also worked.

The compiler error in this scenario also helps showing the project where the error exists as WebApplication3.DNX Core 5.0 which helps me hint at being a core50 error. Thanks again!

@ashelley
Copy link

ashelley commented Nov 3, 2015

@kagamine @seanmerron

Just spent all day trying to get my wrapped libraries to compile. Removing the key dnxcore50 from my project.json in my -beta8 project fix my problem.

Thanks so much!

natemcmaster pushed a commit that referenced this issue Nov 20, 2018
* Add support for executing IHostingStartup in specified assemblies
- Assemblies that are specified in the "hostingStartupAssemblies" configuration (; delimited)
  setting can specify assemblies that use an assembly level attribute (HostingStartupAttribute)
  to specify a type that implements IHostingStartup. This allows hosting environments to
  extend the IWebHostBuilder with platform specific behavior before the application runs.
- Added tests
- Log errors that occur during load and execution of the IHostingStartup
when capture startup errors is off. This happens on start of the application.
- Added debug logging on startup to print out the hosted startup assemblies hosting
processed

#951
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants