[Closed] System.Windows.Forms.Timer Unhandled Exception and escapeEnable = true
Hi, everyone!
Simplest example from the mxs reference:
t = dotNetObject "System.Windows.Forms.Timer"
fn OnTick sender ev =
(
try
( -- some little task in max main thread
print localTime
)
catch()
)
dotnet.addEventHandler t "tick" OnTick
t.interval = 1000
t.start()
escapeEnable = true
-- t.stop()
Now when the timer is active and escapeEnable set to true press and hold Esc key for some time. Max will popup unhandled exception window which is impossible to close. So the user has no chance to save the work.
Can someone suggest a working solution to prevent such behavior, except disabling escapeEnable?
I thought that it is possible to add some timestamp checks to stop timer from execution further, but this doesn’t seem to work.
t = dotNetObject "System.Windows.Forms.Timer"
fn OnTick sender ev =
(
local ts = timeStamp()
if ts - sender.Tag >= (sender.Interval * 1.5) then
(
format "Interval exceeded: %" ((ts - sender.Tag) / sender.Interval)
sender.Stop()
)
else sender.Tag = ts
try
( -- some little task in max main thread
print localTime
)
catch()
)
dotnet.addEventHandler t "tick" OnTick
t.interval = 1000
t.tag = timestamp()
t.start()
escapeEnable = true
-- t.stop()
I don’t have this exception (MAX 2016)
but it might happen I guess.
make some tests:
#1 try to remove “try/catch”
#2 try to move all in local scope:
(
global t = dotNetObject "System.Windows.Forms.Timer"
fn OnTick sender ev =
(
try
( -- some little task in max main thread
print localTime
)
catch()
)
dotnet.addEventHandler t "tick" OnTick
t.interval = 1000
t.start()
)
#3 maybe you have another “background” task that is causing the problem?
2012, 2014, 2016, 2017 & 2020 behave exactly the same. Impossible to close this popup.
Could it be that your 2016 somehow forces escapeEnable to false? As it is the only condition when this script can work safely.
- Try catch isn’t a problem. Removing it doesn’t change a thing.
- Initially this timer is a member of a struct, so it is local and its callback is also local.
- I removed ENU folder, renamed Plugins folder in max root, so there’s nothing left that may interfere with this basic example script. And it still fails… Other users also had this issue, so it is unlikely to be related to my pretty old pc config.
At first I thought that something like this might work. But I was overly optimistic.
fn OnTick =
(
escapeEnable = false
...
...
escapeEnable = true
)
So the only solution available at the moment is to force escapeEnable to false and pray for it to stay disabled while timer is active.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
*********** Exception Text ***********
System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at MXS_dotNet.DotNetObjectWrapper.RunEventHandlers(DotNetObjectWrapper* , Value* target, Value* eventName, Array* handlers, Object[] delegateArgsArray)
at MXS_dotNet.DotNetObjectWrapper.ProcessEvent(DotNetObjectWrapper* , String eventName, Object delegateArgs)
at MXS_dotNet.DotNetObjectManaged.delegate_proxy_type.ProcessEvent(String eventName, Object delegateArgs)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
*********** Loaded Assemblies ********
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4069.0 built by: NET48REL1LAST_B
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
3dsmax
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/3dsmax.exe
----------------------------------------
AssemblyLoader
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/AssemblyLoader.DLL
----------------------------------------
CSharpUtilities
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/CSharpUtilities.DLL
----------------------------------------
ManagedServices
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/ManagedServices.DLL
----------------------------------------
UiViewModels
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/UiViewModels.DLL
----------------------------------------
PresentationFramework
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4110.0
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.dll
----------------------------------------
WindowsBase
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4110.0 built by: NET48REL1LAST_B
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/WindowsBase/v4.0_4.0.0.0__31bf3856ad364e35/WindowsBase.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4110.0 built by: NET48REL1LAST_B
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4001.0 built by: NET48REL1LAST_C
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
PresentationCore
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4110.0 built by: NET48REL1LAST_B
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_64/PresentationCore/v4.0_4.0.0.0__31bf3856ad364e35/PresentationCore.dll
----------------------------------------
System.Xaml
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4110.0 built by: NET48REL1LAST_B
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Xaml/v4.0_4.0.0.0__b77a5c561934e089/System.Xaml.dll
----------------------------------------
Autodesk.Max.Wrappers
Assembly Version: 0.0.0.0
Win32 Version: 16.3.0.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/Autodesk.Max.Wrappers.dll
----------------------------------------
3dsCUIActionTest
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/3dsCUIActionTest.dll
----------------------------------------
3dsmax_custom_Snap
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/3dsmax_custom_Snap.dll
----------------------------------------
Autodesk.Max.StateSets
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/Autodesk.Max.StateSets.dll
----------------------------------------
DaylightSimulation
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/DaylightSimulation.dll
----------------------------------------
FPMaxWpfContent
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/FPMaxWpfContent.dll
----------------------------------------
ManagedBootstrap
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/ManagedBootstrap.dll
----------------------------------------
ManagedNetworkUtilities
Assembly Version: 1.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/ManagedNetworkUtilities.dll
----------------------------------------
MaterialExplorerView
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/MaterialExplorerView.dll
----------------------------------------
MaxWpfContent
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/MaxWpfContent.dll
----------------------------------------
nunit.framework
Assembly Version: 2.4.7.0
Win32 Version: 2.4.7.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/nunit.framework.dll
----------------------------------------
SceneExplorerView
Assembly Version: 1.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/SceneExplorerView.dll
----------------------------------------
Sunlight
Assembly Version: 1.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/Sunlight.dll
----------------------------------------
Autodesk.Max
Assembly Version: 16.3.0.0
Win32 Version: 16.3.0.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/Autodesk.Max.DLL
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4042.0 built by: NET48REL1LAST_C
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.GeneratedCode
Assembly Version: 1.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.GeneratedCode
Assembly Version: 1.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.JScript
Assembly Version: 10.0.0.0
Win32 Version: 14.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.JScript/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.JScript.dll
----------------------------------------
inpjfwqi
Assembly Version: 0.0.0.0
Win32 Version: 14.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.JScript/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.JScript.dll
----------------------------------------
inpjfwqi
Assembly Version: 0.0.0.0
Win32 Version: 14.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.JScript/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.JScript.dll
----------------------------------------
SceneExplorer
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/SceneExplorer.DLL
----------------------------------------
ExplorerFramework
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/ExplorerFramework.DLL
----------------------------------------
WPFCustomControls
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/WPFCustomControls.DLL
----------------------------------------
DevExpress.XtraTreeList.v10.1
Assembly Version: 10.1.7.0
Win32 Version: 10.1.7.10307
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/DevExpress.XtraTreeList.v10.1.DLL
----------------------------------------
AdWindows
Assembly Version: 4.0.24.0
Win32 Version: 4.0.24.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/AdWindows.DLL
----------------------------------------
ExplorerManagement
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/ExplorerManagement.DLL
----------------------------------------
MaxCustomControls
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/MaxCustomControls.DLL
----------------------------------------
DevExpress.XtraEditors.v10.1
Assembly Version: 10.1.7.0
Win32 Version: 10.1.7.10307
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/DevExpress.XtraEditors.v10.1.DLL
----------------------------------------
DevExpress.Utils.v10.1
Assembly Version: 10.1.7.0
Win32 Version: 10.1.7.10307
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/DevExpress.Utils.v10.1.DLL
----------------------------------------
MaxMaterialBindings
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/MaxMaterialBindings.DLL
----------------------------------------
DevExpress.Data.v10.1
Assembly Version: 10.1.7.0
Win32 Version: 10.1.7.10307
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/DevExpress.Data.v10.1.DLL
----------------------------------------
MaxExplorerBindings
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/MaxExplorerBindings.DLL
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
MaxSerialization
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/MaxSerialization.DLL
----------------------------------------
mxsdotNet
Assembly Version: 1.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/mxsdotNet.dlx
----------------------------------------
CoreManagedUiControls
Assembly Version: 16.5.277.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/CoreManagedUiControls.DLL
----------------------------------------
AdApplicationFrame
Assembly Version: 0.0.0.0
Win32 Version: 4.0.19.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/AdApplicationFrame.DLL
----------------------------------------
PresentationFramework.Classic
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework.classic/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.classic.dll
----------------------------------------
PresentationFramework-SystemXml
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework-SystemXml/v4.0_4.0.0.0__b77a5c561934e089/PresentationFramework-SystemXml.dll
----------------------------------------
PresentationFramework.Aero
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework.Aero/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.Aero.dll
----------------------------------------
PresentationFramework-SystemCore
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework-SystemCore/v4.0_4.0.0.0__b77a5c561934e089/PresentationFramework-SystemCore.dll
----------------------------------------
PresentationFramework-SystemData
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4110.0
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework-SystemData/v4.0_4.0.0.0__b77a5c561934e089/PresentationFramework-SystemData.dll
----------------------------------------
UIAutomationTypes
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4110.0 built by: NET48REL1LAST_B
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/UIAutomationTypes/v4.0_4.0.0.0__31bf3856ad364e35/UIAutomationTypes.dll
----------------------------------------
UIAutomationProvider
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4110.0 built by: NET48REL1LAST_B
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/UIAutomationProvider/v4.0_4.0.0.0__31bf3856ad364e35/UIAutomationProvider.dll
----------------------------------------
ATSVault10
Assembly Version: 1.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/stdplugs/AssetTracking/ATSVault10.dll
----------------------------------------
System.Xml.Linq
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
----------------------------------------
xtbhqofq
Assembly Version: 0.0.0.0
Win32 Version: 4.8.4001.0 built by: NET48REL1LAST_C
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
jahtest
Assembly Version: 1.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/mxsdotNet.dlx
----------------------------------------
DNDDependecies
Assembly Version: 1.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/mxsdotNet.dlx
----------------------------------------
User32
Assembly Version: 0.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/mxsdotNet.dlx
----------------------------------------
ResolutionChecker
Assembly Version: 1.0.0.0
Win32 Version: 16.5.277.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/bin/assemblies/mxsdotNet.dlx
----------------------------------------
Vault10WebServices
Assembly Version: 15.3.0.0
Win32 Version: 15.3.0.0
CodeBase: file:///C:/Program%20Files/Autodesk/3ds%20Max%202014/Vault10WebServices.DLL
----------------------------------------
System.Web.Services
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Web.Services/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll
----------------------------------------
******** JIT Debugging ***********
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Hmm… I see a few of my personal .dlx in /bin folder… but other users certainly don’t have these, but still have the exception.
upd. mxsdotNet.dlx is Autodesk dll.
this is from the MXS Help:
escapeEnable
In 3ds Max 9 and higher, the default value of this variableis false . It used to be true in versions prior to 3ds Max 9.
Personally I don’t use escapeEnable many years. So… turn it OFF and forget
PS:
many people mistakenly think that escapeEnable is something about interrupting Max scripts. In fact, this is an interception of the Escape Key, so as not to confuse another process which listen for an interuption – Progress Bar for example, which has its own Cancel. Before, when there was no .NET, WPF, Qt controls with their own built-in key events, it made some sense. But not now any more…
Either the default value isn’t really changed since then or there’s something that sets it to true even at fresh & clean startup.
Anyway, thanks! I somehow missed this info reading the reference.
I already found that it is possible to replace winforms timer with empty auxiliary rollout with only timer control.
It doesn’t throw exception even when escapeEnable is enabled