MonoGame.WpfCore Designer error


I trying to use MonoGame.WpfCore package to use Monogame in WPF
the project builds succesfully but the XAML Designer dosn’t work any way to fix this ?
I am using Visual Studio 2022 Version 17.1.2

System.Runtime.InteropServices.COMException
Error HRESULT E_FAIL has been returned from a call to a COM component.
   at Microsoft.VisualStudio.DesignTools.RuntimeHost.TapOM.ResponseWithError.ThrowIfFailed()
   at Microsoft.VisualStudio.DesignTools.SurfaceDesigner.Documents.SurfaceIsolation.DesignerInstanceManager.<BuildDocumentAsync>d__56.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.DesignTools.XamlSurfaceDesigner.Views.IsolatedSurfaceImageHost.<CreateSurfaceAsync>d__67.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

System.AggregateException
One or more errors occurred.



Is your code still executing in design mode? If so that might be causing errors. I.E. if you have a property like this:

private static bool? _isInDesignMode;
/// <summary>Gets a value indicating whether the controls runs in the context of a designer (e.g. Visual Studio Designer or Expression Blend).</summary>
/// <value><see langword="true" /> if controls run in design mode; otherwise, <see langword="false" />.</value>
public static bool IsInDesignMode
{
    get
    {
        if (!_isInDesignMode.HasValue)
            _isInDesignMode = (bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)).Metadata.DefaultValue;
        return _isInDesignMode.Value;
    }
}

Does your constructor (and any other code that might be getting executing by the designer) do something like this:

public class Sample : WhateverTheWpfCoreBaseClassIs
{
    public Sample()
    {
        if (!IsInDesignMode)
        {
            //Do stuff that utilizes MonoGame, the GraphicsDevice etc
        }
    }

    public override void Update(TimeSpan dt)
    {
        if (IsInDesignMode)
            return;


    }

    public override void Draw()
    {
        if (IsInDesignMode)
            return;

    }
}

I don’t use WpfCore nuget package so not sure what the issue is, but the designer still works for me when using the older Wpf interop stuff (I think this is the code I’m using that works fine: GitHub - ziriax/MonoGame.Framework.WpfInterop: Wpf interop code to host MonoGame controls inside WPF windows but this looks like the older/outdated version of it, I can’t seem to find the newest version of that D3D11Host class) I can paste the code I’m using here if you need it