question-mark
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.

preview7 Duplicate InitializeComponent generated

See original GitHub issue

Describe the bug preview7 generates duplicate InitializeComponents edit: this happens in preview6 too

To Reproduce Steps to reproduce the behavior:

cd ~\Desktop
mkdir issue_11143
cd issue_11143
dotnet new avalonia.xplat
# Upgrade to preview7
(Get-Content .\Directory.Build.props).replace('preview5', 'preview7') | Set-Content .\Directory.Build.props
dotnet build

Result:

C:\Users\doug\Desktop\issue_11143\issue_11143\ViewLocator.cs(10,20): warning CS8767: Nullability of reference types in type of parameter 'data' of 'Control
ViewLocator.Build(object data)' doesn't match implicitly implemented member 'Control? ITemplate<object?, Control?>.Build(object? param)' (possibly because o
f nullability attributes). [C:\Users\doug\Desktop\issue_11143\issue_11143\issue_11143.csproj]
C:\Users\doug\Desktop\issue_11143\issue_11143\Avalonia.NameGenerator\Avalonia.NameGenerator.AvaloniaNameSourceGenerator\issue_11143.Views.MainWindow.g.cs(19
,21): error CS0111: Type 'MainWindow' already defines a member called 'InitializeComponent' with the same parameter types [C:\Users\doug\Desktop\issue_11143
\issue_11143\issue_11143.csproj]
C:\Users\doug\Desktop\issue_11143\issue_11143\Avalonia.NameGenerator\Avalonia.NameGenerator.AvaloniaNameSourceGenerator\issue_11143.Views.MainView.g.cs(18,2
1): error CS0111: Type 'MainView' already defines a member called 'InitializeComponent' with the same parameter types [C:\Users\doug\Desktop\issue_11143\iss
ue_11143\issue_11143.csproj]

Build FAILED.

C:\Users\doug\Desktop\issue_11143\issue_11143\ViewLocator.cs(10,20): warning CS8767: Nullability of reference types in type of parameter 'data' of 'Control
ViewLocator.Build(object data)' doesn't match implicitly implemented member 'Control? ITemplate<object?, Control?>.Build(object? param)' (possibly because o
f nullability attributes). [C:\Users\doug\Desktop\issue_11143\issue_11143\issue_11143.csproj]
C:\Users\doug\Desktop\issue_11143\issue_11143\Avalonia.NameGenerator\Avalonia.NameGenerator.AvaloniaNameSourceGenerator\issue_11143.Views.MainWindow.g.cs(19
,21): error CS0111: Type 'MainWindow' already defines a member called 'InitializeComponent' with the same parameter types [C:\Users\doug\Desktop\issue_11143
\issue_11143\issue_11143.csproj]
C:\Users\doug\Desktop\issue_11143\issue_11143\Avalonia.NameGenerator\Avalonia.NameGenerator.AvaloniaNameSourceGenerator\issue_11143.Views.MainView.g.cs(18,2
1): error CS0111: Type 'MainView' already defines a member called 'InitializeComponent' with the same parameter types [C:\Users\doug\Desktop\issue_11143\iss
ue_11143\issue_11143.csproj]
    1 Warning(s)
    2 Error(s)

Expected behavior A clean build.

Screenshots image

Desktop (please complete the following information):

  • OS:
    • Windows 10 Pro x64 Version 10.0.19044 Build 19044
  • Version [e.g. 0.10.0-rc1 or 0.9.12]
    • 11.0.0-preview7

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
replaysMikecommented, May 13, 2023

also had an issue with the ViewLocator which was not listed in Breaking Changes, part of the default Avalonia UI template in Visual Studio.

1reaction
slater1commented, Apr 26, 2023

For those who arrive here with the same issue:

it will conflict with build in generator now in the linked breaking changes refers among other things to duplicate generation of InitializeComponent.

I got my app updated from preview5 to 7. There were a few things broken whose fixes I found digging through pull requests. All expected for a preview version.

Thanks for the support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Duplicate Model instantiated from InitializeComponent()
I have a model class DeviceModel instantiated from App.xaml.cs. This model implements INotifyPropertyChanged interface. ... This works great! I ...
Read more >
Updated Modern Code Generation for WinForm's ...
When you design a WinForms Form, it gets generated into a method called InitializeComponent. When you reopen that Form, it gets recreated by ......
Read more >
Every InitializeComponent() reference in my project is ...
Every InitializeComponent() reference in my project is throwing an exception, I'm stumped. Any ideas? · Try a Clean All, then a rebuild. ·...
Read more >
11.0.0 Preview 7 · AvaloniaUI Avalonia · Discussion #11117
This discussion was created from the release 11.0.0 Preview 7. ... CS1501: No overload for method 'InitializeComponent' takes 2 arguments.
Read more >
Visual Studio 17.2.6 Breaks CommunityToolkit.Mvvm #6792
It's odd that msbuild would do that, It feels like the compiler should be modified to give a diagnostic and/or dedupe the duplicate...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found