Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio for Windows v16.3.4 - 'App' does not contain a definition for 'InitializeComponent' and no accessible extension method 'InitializeComponent' #1848

Closed
ghuntley opened this issue Oct 15, 2019 · 26 comments
Assignees
Labels
area/vswin Categorizes an issue or PR as relevant to Visual Studio for Windows difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools

Comments

@ghuntley
Copy link
Member

ghuntley commented Oct 15, 2019

Current behavior

Application compiles fine but the following error is erroneously displayed in the Visual Studio error list:

Severity	Code	Description	Project	File	Line	Suppression State
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?)	App17.Droid, App17.Wasm, App17.iOS	C:\Users\ghuntley\Downloads\App17\App17\App17.Shared\App.xaml.cs	38	Active

image

How to reproduce it (as minimally and precisely as possible)

Unzip https://github.com/unoplatform/uno/files/3697856/App17.zip

Troubleshooted as follows:

  1. Close Visual Studio, delete App17 folder and extract fresh
  2. Open Visual Studio -> Right Click Build Solution -> Error
  3. Close and re-open Visual Studio
  4. Open Visual Studio -> Right Click Build Solution -> Error
  5. Upgrade Uno.UI from 2.0.282-dev.3016 to 2.0.512-dev.3360
  6. Right Click Build Solution -> Error
  7. Close and re-open Visual Studio
  8. Open Visual Studio -> Right Click Build Solution -> Error

This did not happen in releases before v16.3.4

Environment

Details

Microsoft Visual Studio Enterprise 2019
Version 16.3.4
VisualStudio.16.Release/16.3.4+29409.12
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Enterprise

Visual C++ 2019 00435-60000-00000-AA184
Microsoft Visual C++ 2019

Application Insights Tools for Visual Studio Package 9.1.00913.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019 16.3.285.24939
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019 16.3.285.24939
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.3.285.24939
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.3.285.24939
Azure Functions and Web Jobs Tools

C# Tools 3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Child Process Debugging Power Tool 1.0
Power tool to add child process debugging to Visual Studio.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.2.0 (d16-2@8b56e20)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

FormatDocumentOnSave 1.0
Enables auto formatting of the code when you save a file. Visual Studio supports auto formatting of the code with the CTRL+E,D or CTRL+E,F key shortcuts but with this extension the command 'Format Document' is executed on Save.

You can find the source here: https://github.com/Elders/VSE-FormatDocumentOnSave

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

JetBrains ReSharper Ultimate 2019.2.2 Build 192.0.20190828.114715
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2019 JetBrains, Inc.

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 0x10 - v2.9.20816.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.0.83+gbc8a4b23ec
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 16.3.7 (9d260c5)
Support for debugging Mono processes with Visual Studio.

Node.js Tools 1.5.10807.1 Commit Hash:4d3cf548113f5a53a02d83a877ee24e764b2cde4
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager 5.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

OzCodePackage Extension 1.0
OzCodePackage Visual Studio Extension Detailed Info

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Snapshot Debugging Extension 1.0
Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.61908.27190
Microsoft SQL Server Data Tools

Syntax Visualizer 1.0
An extension for visualizing Roslyn SyntaxTrees.

Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools 16.0.10821.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual C++ for Cross Platform Mobile Development (Android) 16.0.29230.54
Visual C++ for Cross Platform Mobile Development (Android)

Visual F# Tools 10.4 for F# 4.6 16.3.0-beta.19455.1+0422ff293bb2cc722fe5021b85ef50378a9af823
Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake

Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 16.3.0.277 (d16-3@c0fcab7)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.3.0.246 (remotes/origin/d16-3@bd2f86892)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.3.565 (27e9746)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 10.0.3.0 (d16-3/4d45b41)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: mono/mono@5608fe0abb3
Java.Interop: xamarin/java.interop@5836f58
LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94
LibZip: nih-at/libzip@b95cf3fd
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools@cb41333

Xamarin.iOS and Xamarin.Mac SDK 13.4.0.2 (e37549b)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

@ghuntley ghuntley added kind/bug Something isn't working area/vswin Categorizes an issue or PR as relevant to Visual Studio for Windows kind/maintainer-experience labels Oct 15, 2019
@ghuntley
Copy link
Member Author

Still reproducible in Visual Studio for Windows v16.3.5

@kzu
Copy link

kzu commented Oct 17, 2019

Any particular reason you're not targetting net472 instead of net462? (had to install the targeting pack). You could potentially streamline that scenario by referencing https://www.nuget.org/packages/Microsoft.NETFramework.ReferenceAssemblies.net462 perhaps?

I'm looking into this, btw :)

Microsoft .NET Framework Reference Assemblies

@jeromelaban
Copy link
Member

Thanks @kzu ! Referencing older target frameworks is collection of chained issues, but basically, we're staying on previous versions because of our inability to target specific versions of Xamarin.iOS which can cause backward compatibility issues (compiled code may reference apis that are not available in VS builds that are in previous VS versions).

At this point, we're building on vs2017, but maybe with the recent release of the boots azure devops task that will enable us to move forward.

@kzu
Copy link

kzu commented Oct 18, 2019

Makes sense. Yeah, we switched everywhere we could to net472 as soon as we could to avoid the entire facade nugets mess for NS2 support, results in far cleaner deps.

@francoistanguay francoistanguay added this to the Urgent milestone Aug 29, 2020
@jeromelaban jeromelaban removed this from the HighPriority milestone Sep 1, 2020
@agneszitte agneszitte added project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools and removed kind/consumer-experience labels Sep 21, 2020
@michalss
Copy link

michalss commented Oct 10, 2020

I have same issue, not matter i do still this error appearing ... :( VS 16.7.5 Is there any fix yet pls ? I cannot even touch any xaml file so uno is not working at this moment it seems.

@jeromelaban
Copy link
Member

There is no fix for this at this yet, It may start to change with VS 16.8 when C# 9.0 is enabled.

@jeromelaban
Copy link
Member

Also note that if you build the project, close the solution and reopen the solution, the error disapears.

@rwomack
Copy link

rwomack commented Nov 21, 2020

It started occuring for me after upgrading the Nuget package.

@jeromelaban jeromelaban added the difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. label Feb 15, 2021
@Luk164
Copy link

Luk164 commented Mar 14, 2021

This occured to me when I was trying UNO for first time, seems it fits this issue. Screenshot:
image

Extra info:

  • Fresh template, no changes, latest uno platform VS extension
  • VS CE 2019 (16.9.1) + ReSharper both latest at time of writing

While this issue mentions net472 instead of net462, all I see is .netCore 3.1 and .NET 5, but I am new to this platform so it could just be a misunderstanding.

@jeromelaban
Copy link
Member

@Luk164 The situation is improving regularly as VS versions are improving, but you can see common resolution steps here.

@sigmarsson
Copy link

@jeromelaban , okay so no VS Preview is advised to compile with ?

@sigmarsson
Copy link

I witness the same error with VS 16.10.0 Preview 1.

image

image

<TargetFramework>net5.0-windows10.0.18362.0</TargetFramework>

But only the Wasm head is having this error.

@sigmarsson
Copy link

I followed through the common resolution steps but to no avail. Is there another hint ?

@jeromelaban
Copy link
Member

If you're still getting this error, it's only caused by the IDE cache. Once you've built the solution, restart VS.

@MartinZikmund MartinZikmund added difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jun 1, 2021
@sigmarsson
Copy link

I keep witnessing this error;

image

with the latest packages ;

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
    <PackageReference Include="Prism.DryIoc.Uno.WinUI" Version="8.1.97" />
    <PackageReference Include="Prism.Uno.WinUI" Version="8.1.97" />
    <PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.1.0-dev.1" />
    <PackageReference Include="Uno.WinUI.WebAssembly" Version="3.8.0-dev.310" />
    <PackageReference Include="Uno.WinUI.RemoteControl" Version="3.8.0-dev.310" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="3.0.0-dev.85" />
    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="3.0.0-dev.85" />
  </ItemGroup>

Visual Studio (was restarted between clean & build):
image

@sigmarsson
Copy link

sigmarsson commented Jun 14, 2021

@jeromelaban maybe it's just me does not understand the full application stack but why are we actually obligated to invoke this parameterless InitializeComponent() in that explicit manner ?

For example the only duty with code behinds while using Stylet MVVM minimalist framework is SHIFT + DEL. Never a call of InitializeComponent().

That fosters the ViewModel-First approach, perhaps you like it and see a chance Uno will fusion with that ? Have a nice day.

@jeromelaban
Copy link
Member

Please make sure to follow the code of conduct when exchanging with this community.

App.InitializeComponent() is required for the whole application to work properly, and is also required when running on Windows. You can view the content of that function in the generated code folder once you have built the application. You need to invoke it in all cases.

@mmarinchenko
Copy link
Contributor

@sigmarsson

The Uno platform is not an MVVM framework. It's more like a "bridge" between UWP/WinUI and systems that don't have it (but have a .NET runtime). So I think your claim should be directed to Microsoft 😉

You can see this link for some official information about InitializeComponent().

@sigmarsson
Copy link

@jeromelaban, violating content has been erased.

@ghost
Copy link

ghost commented Jul 7, 2021

This is still an issue in VS 16.10.3. Is there a solution on the horizon?

@jeromelaban
Copy link
Member

@GRS-Leedo The upcoming support for .NET 6 will improve the situation.

@brendanalexdr
Copy link

Getting this too. Using Uno Platform

@sushi1992
Copy link

Me too. Uno is pointless for me now since I can't build for wasm. Using 2022 and 2019. Neither works for this

@jeromelaban
Copy link
Member

@sushi1992 have you followed the suggestions from #1848 (comment)?

@xperiandri
Copy link
Contributor

I suppose that this can be closed. Very old versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vswin Categorizes an issue or PR as relevant to Visual Studio for Windows difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools
Projects
None yet
Development

No branches or pull requests