Skip to content

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

Closed as duplicate

Description

@ajpinedam

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

Activity

  1. added
    kind/bug
    triage/untriaged
    difficulty/tbd
    on Dec 8, 2024
  2. DevTKSS commented on Dec 12, 2024

    @DevTKSS
    Contributor

    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

  3. DevTKSS commented on Feb 21, 2025

    @DevTKSS
    Contributor

    @MartinZikmund could you check if this should be closed here, it's already listed and talked about in the mvux repository itself where it belongs corretly to
    unoplatform/uno.extensions#2648

  4. MartinZikmund commented on Feb 24, 2025

    @MartinZikmund
    Member

    Indeed, closing as duplicate

  5. github-actions commented on May 7, 2026

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests.

  6. locked as resolved and limited conversation to collaborators on May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty/tbdkind/bugtriage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions