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

impossible add to designer (VS c# WPF) #6

Open
Titibo26 opened this issue Jan 18, 2019 · 5 comments
Open

impossible add to designer (VS c# WPF) #6

Titibo26 opened this issue Jan 18, 2019 · 5 comments

Comments

@Titibo26
Copy link

Hey,

When i try to add both UIOpenTKControl or threading one into the designer of my C# apps, it gives me an error :

"ArgumentNullException : Value can't be null.
Parameter name : window"

I think it's making some trouble on my XAML code. Tried to fixe it but i didn't find the solution.
I tried to reinstal everything. Same error occurs with the example solution.
BackTrace is :

à System.Windows.Interop.WindowInteropHelper..ctor(Window window)
à OpenTkControl.OpenTkControlBase.OnLoaded(Object sender, RoutedEventArgs args)
à OpenTkControl.UiOpenTkControl.OnLoaded(Object sender, RoutedEventArgs args)
à OpenTkControl.OpenTkControlBase.<.ctor>b__49_5(Object sender, RoutedEventArgs args)
à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
à System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
à System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
à System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
à System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
à MS.Internal.LoadedOrUnloadedOperation.DoWork()
à System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
à System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
à System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
à System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
à System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Thank you very much,

@jayhf
Copy link
Owner

jayhf commented Jan 18, 2019

What is the XAML code you tried to add it with? Did you take a look at the example code?

@Titibo26
Copy link
Author

Hi,

Ofc i tried the example code but i got the same error. Today i tried it on an other computer so i believe it's in the code or i'm doing something wrong :(.

Here is the XAML code added automatically :

<Window x:Class="OpenTkControlExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:openTkControl="clr-namespace:OpenTkControl;assembly=OpenTkControl"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <openTkControl:ThreadOpenTkControl x:Name="OpenTkControl" GlRender="OpenTkControl_OnGlRender" ExceptionOccurred="OpenTkControl_OnExceptionOccurred"/>
    </Grid>
</Window>

error_opentkcontrol

@jayhf
Copy link
Owner

jayhf commented Jan 28, 2019

The control can't render properly within the designer view, but it should work fine when you actually run the code. The easiest solution to this issue is disabling project code in the designer. See this for more information:
https://docs.microsoft.com/en-us/visualstudio/designers/debugging-or-disabling-project-code-in-xaml-designer?view=vs-2017
Alternatively, you can modify the code to add checks to see if its running in the designer and disable anything that calls a function that won't work properly.

@rickberkers
Copy link

Could this merged fix be updated on NuGet?

@jayhf
Copy link
Owner

jayhf commented Sep 24, 2020

@rickberkers Yes, I'll try to get the other PR merged and then put this on NuGet sometime this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants