-
Notifications
You must be signed in to change notification settings - Fork 124
Build error when referencing .NET Framework 4.5 class libraries #127
Comments
@BillHiebert thoughts? |
Did some more testing, and it looks like using .NET Framework 4.6 in both the site and the class library appears to work, as does using .NET Framework 4.0 in the class library combined with .NET Framework 4.5 in the website. It just seems to be an issue when using .NET Framework 4.5 in the class library. Another related bug while I was testing this: Selecting ".NET Framework 4.6" in the "New Project" dialog in VS2015 still sets Edit: Now I'm not so sure - Using .NET Framework 4.6 both worked in my small test project, but didn't work in my real larger site, I'm still seeing a lot of compilation "errors" in VS that aren't really errors: (notice it says "Build Succeeded" at the bottom. The site does work properly if I run it) |
Okay I think I figured this out. My repro steps weren't 100% correct and I actually missed a step when I wrote them out. The issue is that when you change the target framework version for an assembly (such as a Class Library), its corresponding Workaround: Manually update the |
TFS:149636 |
The GitHub Issue Tracker for the aspnet/Tooling repo is being deprecated in favor of Visual Studio's Report a Problem tool. If this issue is still a problem with the RTW release of Visual Studio 2017, please report a new issue using the Report a Problem tool. While you can still use .NET Core and ASP.NET Preview tools with Visual Studio 2015, Visual Studio 2017 is now the officially supported tool for developing .NET Core and ASP.NET Core projects. By using the Report a Problem tool (available in both VS 2017 and VS 2015), you can collect detailed information about the problem, and send it to Microsoft with just a few button clicks. See Visual Studio's Talk to Us page for more details. Please use the discussion topic here for feedback and questions on the deprecation of this issue tracker. Thanks! |
This works fine in VS2017 with the latest tooling |
Repro:
project.json
so it only targets .NET 4.5.1 (dnx451
inframeworks
section)Startup.cs
to use a class from the class library (eg.var foo = new ClassLibrary1.Class1();
)This results in error CS0246 ("The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)") in Visual Studio. However, this just appears to be a design-time issue, as the site does actually execute properly and there are no errors in the "Output" tab.
Note: This appears to be specific to .NET Framework 4.5. Switching the class library to use .NET Framework 4.0 makes it work as expected (no build errors)
Update: Okay I think I figured this out. My repro steps weren't 100% correct and I actually missed a step when I wrote them out. The issue is that when you change the target framework version for an assembly (such as a Class Library), its corresponding
project.json
in thewrap
directory is not updated (eg. to changenet40
tonet45
). I encountered this since I changed a library from .NET Framework 4.0 to .NET Framework 4.5.Workaround: Manually update the
project.json
files, or delete thewrap
directory and re-add the reference in Visual Studio.The text was updated successfully, but these errors were encountered: