dotnet / dotnet/wpf

change App project to DLL problems

Open
#2,812 11 comments 0 reactions 1 assignee Claimed by @vatsan-madhavan View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 3.1
* Visual Studio 2019 Version 16.5.0 (new / fresh instalation and new project)
after update to 16.5.1 same problems

**Description:**
I have WPF NetFramework app converted in to DLL where I used App.Xaml. Now I am trying to do same with WPF Net Core.

---

**1. Problem**
I can not change App.Xaml to Page from Properties. I got this error:

> Property Value is not valid.
> An error has occurred while saving the edited properties listed below:
> Build Action
> One or more values are invalid. Only included item inside the project can be moved.
> Parameter name: currentItem

same problem when I change Window from Page to Content and back

> An error has occurred while saving the edited properties listed below:
> Build Action
> One or more values are invalid. Cannot add 'MainWindow.xaml' to the project, because the path is explicitly excluded from the project (C:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.targets (35,5)).

---

**2. Problem**
when WPF app is converted to ClassLibrary (DLL) then Windows and Application can not use InitializeComponent() function. And when I try build it I got this error:

> SeverityCodeDescriptionProjectFileLineSuppression State ErrorCS0103The name 'InitializeComponent' does not exist in the current contextWpfApp1CoreE:\PathToMyProject\WpfApp1Core\WpfApp1Core\MainWindow.xaml.cs25Active

---

**3. Problem**
I created another project WPF Net.Core app and InitializeComponent working, but error when changing properties for Xaml is still here. When I try compile it, I got this errors:

> 1>C:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9): error MC1002: Library project file cannot specify ApplicationDefinition element. 1>C:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9): error BG1003: The project file contains a property value that is not valid.

> SeverityCodeDescriptionProjectFileLineSuppression State ErrorNETSDK1022Duplicate 'Page' items were included. The .NET SDK includes 'Page' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultPageItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'App.xaml'WpfApp2CoreC:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.targets69

> SeverityCodeDescriptionProjectFileLineSuppression State ErrorNETSDK1022Duplicate 'Page' items were included. The .NET SDK includes 'Page' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultPageItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'MainWindow.xaml'WpfApp2CoreC:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.targets69

---
btw. I posted it [there](https://developercommunity.visualstudio.com/content/problem/958304/wpf-core-app-change-to-dll-problems.html), but I was redirected to post it here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.