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

The type or namespace name 'MainViewModel' could not be found in the global namespace (are you missing an assembly reference?) #19036

Open
ajpinedam opened this issue Dec 8, 2024 · 1 comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@ajpinedam
Copy link
Contributor

Current behavior

Getting error:

The type or namespace name 'MainViewModel' could not be found in the global namespace (are you missing an assembly reference?)

When creating a public property of the Type of the ViewModel (MVUX generated file) from the Page code behind.

Expected behavior

No response

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

Using the default template, create an app and add a property of the type generated from the MVUX Model

public sealed partial class MainPage : Page
{
    public MainViewModel VM { get; } 

    public MainPage()
    {
        this.InitializeComponent();
    }
}

Workaround

using internal instead of public

public sealed partial class MainPage : Page
{
    internal MainViewModel VM { get; } 

    public MainPage()
    {
        this.InitializeComponent();
    }
}

Works on UWP/WinUI

None

Environment

Uno.SourceGenerationTasks

NuGet package version(s)

"Uno.Sdk": "5.5.54"

Affected platforms

WebAssembly, Android, Skia (WPF), Skia (Linux X11), Skia (macOS), Skia (Linux Framebuffer), Skia (GTK)

IDE

Visual Studio 2022

IDE version

17.12.1

Relevant plugins

No response

Anything else we need to know?

It works on WinAppSDK Targets

@ajpinedam ajpinedam added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Dec 8, 2024
@DevTKSS
Copy link
Contributor

DevTKSS commented Dec 12, 2024

Have had Similar issue, can you check on your workaround if it really not throws a NullReferenceException due to x: Bind to command for example?
Related to:
unoplatform/uno.extensions#2629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

2 participants