dotnet / dotnet/wpf

Can't create Custom Control without this error

Open
#9,509 1 comment 0 reactions 0 assignees View on GitHub
:mailbox_with_no_mail: waiting-author-feedback Needs minimal repro project
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

![image](https://github.com/user-attachments/assets/0022cb84-4e0a-400e-9848-de008d5d5566)
There's nothing to say honestly, I just tried creating a Custom Control and this keeps happening.

What I tried:
-restarted VS
-repaired VS
-tried different filenames

### Reproduction Steps

Click Add > New Item > C# Items > Custom Control (WPF)

### Expected behavior

Create a Custom Control file

### Actual behavior

After building, it'll tell you that you can't have two partial classes with different base components or something close to that effect, that's because then on build it generates a Generic.g.cs and a Generic.g.cs.i which then contain basic info about the class, like initialization, etc, BUT this also results in said error and as soon as I try to remove/replace, overwrite the file AND BUILD it does it again of course

The two Generic files are the identical, so here's their contents:
`#pragma checksum "..\..\..\..\Themes\Generic.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "63F4B9E80A4B5A3A68BFB8979E63A290EB92DAED"
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------

using Listen.UserControls;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;

namespace Listen.UserControls {


///
/// PopupButton
///
public partial class PopupButton : System.Windows.ResourceDictionary, System.Windows.Markup.IComponentConnector, System.Windows.Markup.IStyleConnector {

private bool _contentLoaded;

///
/// InitializeComponent
///
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "8.0.7.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/Listen;component/themes/generic.xaml", System.UriKind.Relative);

#line 1 "..\..\..\..\Themes\Generic.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);

#line default
#line hidden
}

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "8.0.7.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
this._contentLoaded = true;
}

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "8.0.7.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:

#line 99 "..\..\..\..\Themes\Generic.xaml"
((System.Windows.Shapes.Path)(target)).MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.changeOpen);

#line default
#line hidden
break;
}
}
}
}

`

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

I literally can't make any further Custom Controls, please help me qwq

### Configuration

.NET 7
Windows 11 Pro - Version 10.0.22631 Build 22631
x64
No idea

### Other information

_No response_

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.