[Closed] dotNet WPF window using Maxscript
Right so I managed to create a WPF window using maxscript but for some reason when I opened another window maxscript crashes. Sometimes the window doesn’t open and i get a runtime error saying – dotNet runtime exception: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Anybody know why. I really want this to work because WPF controls offer way more than winforms controls.
Could somebody try it there end. It may be my system.
heres the small code
myWindow = dotNetObject "System.Windows.Window"
myWindow.Show()
I guess I’ll have to put my ideas on hold then until I can get a 64bit system. Thanks for the links. Don’t know why sometimes it opens though.
I feel your pain.
The only way I was able to get WPF integration working reliably through maxscript was to re-compile the mxsdotnet.dlx plugin in DEBUG mode.
I found that I didn’t need to modify anything, just compile and replace the plugin that ships with Max. The code is in the SDK in the samples\maxscript\mxsdotNet folder.
[I just checked and this ‘fixes’ the crash bug in your simple case for Max 2010 32 bit and it should work in Max9 through 2009 as well …I’ve be trying to leverage WPF in Max for a while :/]
.biddle
So Mike? This corrects the error on 32bit? Can we get the recompile from you?
it is working here too !
the only difference is the file got bigger with the Debug code
thanks biddle , now i Can Get Into Media Assemblies :applause:
You can try compiling in release mode, I just got sick and tired of trying to pin down what worked with what and have stuck with the debug builds. If it did crash I could load it in the debugger.
Paul, what version(s) do you need a mxsdotnet.dlx for?
Let me know and I’d be happy to build ’em.
I’ve attached 2010 32 bit. (Make sure you save your original before you stomp it)
Here’s a little WPF demo.
I just verified that it works as far back as Max 9 (32bit) as long as you have a recompiled MXSDotNet.dlx
[EDIT: Whoops! The version I attached doesn’t properly handle keyboard accelerators so the text input controls don’t get any keystrokes. My bad, I’ll fix it & upload again]
[EDIT#2: fixed the text input]
Thanks Mike, I don’t know if I can do anything with this as I don’t really know what it does yet. I have lots of clients still on 32 bit so at least I can test it out now and see what i can do.
I think the biggest takeaway is that you separate all the ‘ui’ code out into xaml leaving only the binding to events in a maxscript loader.
The xaml source file in that little demo was my first attempt to fiddle around with xamlpad.exe and see if I could something to work.