max2027 crashes when using maxscript to display a WPF window

max2027 crashes when using maxscript to display a WPF window

lgedZV4XV
Explorer Explorer
1,587 Views
37 Replies
Message 1 of 38

max2027 crashes when using maxscript to display a WPF window

lgedZV4XV
Explorer
Explorer

In 3dsmax 2027, any WPF window created with maxscript will crash when show it, for example:

(dotnetObject "System.Windows.Window").Show()

 

0 Likes
Accepted solutions (1)
1,588 Views
37 Replies
Replies (37)
Message 2 of 38

spacefrog_
Advisor
Advisor

Can confirm the crash ( Works in 2026 )

just for completeness, also happens if you do something like

w= dotnetObject "System.Windows.Window"
w.Show()

w is a valid window object and  one can set properties etc ...

 


Josef Wienerroither
Software Developer & 3d Artist Hybrid
0 Likes
Message 3 of 38

lgedZV4XV
Explorer
Explorer

It works fine in max2010-2026, only crashs in max2027..

0 Likes
Message 4 of 38

A娘
Advocate
Advocate

only dynamical wpf window throw error , when write as xaml in a dll , run normal

0 Likes
Message 5 of 38

lgedZV4XV
Explorer
Explorer

If you show the window in maxscript, the wpf window written in the dll will also crash.

w = dotnetObject "YourDll.YourWindow"
w.Show() --Crash!

w = (dotnetClass "YourDll.YourWindow").GetWindow()
w.Show() --Crash!

Only WPF dlls written in pure c# that don't interact with maxscript don't crash, but there is a lot of interaction in many projects. is Autodesk aware of this problem?

0 Likes
Message 6 of 38

MartinBeh
Advisor
Advisor

FYI, the bug has been reported to the team.

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
Message 7 of 38

ads_decatae
Autodesk
Autodesk

Thanks again for that @MartinBeh ! 



Elena de Catalina
Sr. QA Analyst
Entertainment Creation Products, ECP
0 Likes
Message 8 of 38

lgedZV4XV
Explorer
Explorer

Is there any way to fix this bug?

0 Likes
Message 9 of 38

maxencoding
Community Visitor
Community Visitor

I've been following this issue closely, refreshing the page almost daily for new replies, hoping to find out when it will be fixed or if there are any temporary solutions.  @MartinBeh 

0 Likes
Message 10 of 38

MartinBeh
Advisor
Advisor
Accepted solution

All I can say is that is has been logged into the official bug report database - not idea when/how/for which version of 3ds Max this will be fixed, sorry.

Maybe one of the more dotNet savvy folks around here knows a workaround until there is an update that fixes this for good?

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes
Message 11 of 38

lgedZV4XV
Explorer
Explorer

Thanks all the same!

0 Likes
Message 12 of 38

denisT.MaxDoctor
Advisor
Advisor

If you are reporting a crash, please provide a bit more detail about how it happens.

Does it crash immediately on Show(), after the window appears, or when the window is closed?

Also, are there any error messages or outputs shown anywhere:
- MAXScript Listener
- Autodesk crash dialog (CER)
- any other console or log output

Right now most reports only say “it crashes”, but without the actual error output it is difficult to understand whether this is a WPF issue, a .NET hosting issue, or something else.

0 Likes
Message 13 of 38

maxencoding
Community Visitor
Community Visitor

As mentioned above, simply open 3ds Max 2027 and execute the code `(dotnetObject "System.Windows.Window").Show()` in the script editor. 3ds Max will freeze completely, with no response or output. This is the simplest method I can verify. In my personal WPF project, the UI displays correctly if only `show` is called, but if `set` or `get` is used to interact with the UI, the same problem occurs: 3ds Max freezes and displays no output.

0 Likes
Message 14 of 38

spacefrog_
Advisor
Advisor

This is what i get:

spacefrog__0-1779162941065.png

 


Josef Wienerroither
Software Developer & 3d Artist Hybrid
0 Likes
Message 15 of 38

denisT.MaxDoctor
Advisor
Advisor

This error message is much better than nothing.

0 Likes
Message 16 of 38

denisT.MaxDoctor
Advisor
Advisor

I don't have version 2027, and I don't need to install it yet...

So I recommend trying something like this first:

w = dotnetObject "System.Windows.Window"
w.Title = "WPF Test"
w.Width = 300
w.Height = 200

hlp = dotnetObject "System.Windows.Interop.WindowInteropHelper" w
hlp.Owner = windows.getMAXHWND()

w.Show()

We need to figure out where the problem is.

0 Likes
Message 17 of 38

MartinBeh
Advisor
Advisor

This causes 3ds Max to freeze up for 20 seconds and then fast-exit to desktop, no error message.

This is what the Listener shows while doing so:

MartinBeh_0-1779206853051.png

 

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes
Message 18 of 38

denisT.MaxDoctor
Advisor
Advisor

how is about ShowDialog() instead?

there is another way to try:

w = dotnetObject "System.Windows.Window"
w.Title = "WPF Test"
w.Width = 300
w.Height = 200


m = (w.GetType()).GetMethod "Show"
m.Invoke w #()


In theory, all should work the same... but it's definitely a MAX's bug, and there might stay some ways that aren't broken.

0 Likes
Message 19 of 38

MartinBeh
Advisor
Advisor

Again, the UI freezes up, fast-exit to desktop.

Here is the Listener output:

MartinBeh_0-1779209810508.png

 

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes
Message 20 of 38

denisT.MaxDoctor
Advisor
Advisor

What would I recommend if I urgently needed this in Max 2027 and couldn’t wait for Autodesk to fix the bug?

I would do the following: first, check whether Windows Forms still work. If they do, then I would wrap the WPF window inside a Windows Forms window and launch it through the Form.

 

0 Likes