Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating an OpenGL control in a wpf window on windows 7

I have created an OpenGL control in C++ and wish to use this in a WPF application. I have successfully accomplished this and it works fine on Vista and XP machines but when I open my project on a windows 7 machine the WPF design window will not display. When I try to run the program I get the exception:

"Cannot create instance of 'Window1' defined in assembly 'LabUserInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 9."

'LabUserInterface' is where my OpenGL stuff lives. Also I have this error in the WPF window:

"Type 'MS.Internal.Permissions.UserInitiatedNavigationPermission' in Assembly 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable."

like image 576
Paul Jones Avatar asked Feb 11 '10 14:02

Paul Jones


1 Answers

Two possibilities:

1) UAC, pathing issue, dependency path issue, .NET security or some other permissions issue (maybe run as administrator) to test. Or make sure your assembly has visibility to all dependencies and correct permissions (i.e. private if in bin folders or next to app, public if in gac or outside of app space).

2) Also, make sure you can run OpenGL on the win7 box. Could be a video driver or something trying to enumerate the video profiles on the card. Update your video card drivers. If using a shared OpenGL version make sure it is present on the machine.

I know that when you make a C++ control in .NET security issues are a top problem. Be sure your C++ control has visibility into the opengl dlls (if shared) and that they are in the loading path (drop them all in C:\windows\system32 if all else fails to be sure they can be seen or local in the private assembly folder (bin)).

We had this same problem with a image toolkit for PVR and it turned out one dll was not in the dependency path. A good tool is DependencyWalker for checking: http://dependencywalker.com/

like image 88
Ryan Christensen Avatar answered Oct 05 '22 08:10

Ryan Christensen