Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mixing WPF project and ASP.Net Core Class Library causes build errors

See original GitHub issue

I have an existing WPF application which I’ve converted from .NET Framework to .NET Core 3.1. I’m trying to add a REST API to this application which shares data so it’s desired to have it in the same process. The current design has the REST API as a class library project (also .NET Core 3.1) and run it on a separate thread started from the WPF app.

When a project reference to the API library is added to the WPF application it fails to build. If the reference is removed it builds just fine.

Here are the build errors:

Error	MC1000	Unknown build error, 'Could not find type 'System.Web.PreApplicationStartMethodAttribute' in assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Web.dll'.' 	AVIF	C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets	225	
Error	CS1061	'App' does not contain a definition for 'InitializeComponent' and no accessible extension method 'InitializeComponent' accepting a first argument of type 'App' could be found (are you missing a using directive or an assembly reference?)	AVIF	C:\Users\kgillibrand\Documents\Work\Source\VtmInterfaces\AvlGpsApp\AVIF\App.xaml.cs	53	Active
Error	CS0039	Cannot convert type 'System.Windows.Window' to 'AVIF.MainWindow' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion	AVIF	C:\Users\kgillibrand\Documents\Work\Source\VtmInterfaces\AvlGpsApp\AVIF\App.xaml.cs	234	Active

I assume the 1st error is the most relevant.

Is this scenario supported? Are there .csproj changes that I need to make?

Here are the csproj files. WPF App Rest API


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

Pilchiecommented, Oct 11, 2021

It’s difficult to mix the two in the same project, because they have different targets pulled in by their different SDKs. I think the recommendation is to put one in a separate project and have a project reference to it from the other.

Moving to the SDK repo though.

marcpopMSFTcommented, Apr 19, 2023

Closing old issues, please reactivate if this is still a problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mixing WPF project and ASP.Net Core Class Library ...
When a project reference to the API library is added to the WPF application it fails to build. If the reference is removed...
Read more >
Visual Studio displaying errors even if projects build
Solution Explorer -> Find the file with the unrecognized class in it. · Click Show All Files at the top of the Solution...
Read more >
Trying to make a class class Library and getting some odd ...
Hi All. The title tells the table. I try to all the dll to a project and get the error shown in the...
Read more >
Using .NET Standard with Full Framework .NET - Rick Strahl
Using .NET Standard on full .NET Framework is a mixed bag because the behavior of .NET Standard differs depending on which version of...
Read more >
Rider can't compile solution with mixed .net core and . ...
I tried to create an ASP.NET Core Web App project mixed with a Bridge.NET class library, which is a .net framework project, only...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found