Jump to content

Unhandled Exception Error Help


Recommended Posts

Hello All,

recently i have been trying to use Autoit to open an application. I have successfully used Autoit to load the app but have encountered a strange problem where once the App has been opened using AutoIT an Unhandled Exception Error is produced.

This error does not appear if i manually open the App, therefore i think it has something to do with AutoIt.

The script code i am using is:

#include <Constants.au3>
#include <MsgBoxConstants.au3>

run("C:\MyApp\MyApp.exe", "C:\MyApp", @SW_SHOWMAXIMIZED)

winwait("[TITLE:MyApp]")

Exit

As you can see its a very basic script. There is a clear difference between autoit opening the App and manually opening the App.

The error message i get is:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Invalid name.
Parameter name: name
   at System.Security.AccessControl.NativeObjectSecurity.CreateInternal(ResourceType resourceType, Boolean isContainer, String name, SafeHandle handle, AccessControlSections includeSections, Boolean createByName, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext)
   at System.Security.AccessControl.FileSystemSecurity..ctor(Boolean isContainer, String name, AccessControlSections includeSections, Boolean isDirectory)
   at System.Security.AccessControl.DirectorySecurity..ctor(String name, AccessControlSections includeSections)
   at TrwVisionClient.Model.PgmWriter.HasWriteAccess(String path)
   at TrwVisionClient.Presenter.MainPresenter.View_OnGetPgmRequest()
   at TrwVisionClient.View.MainView.StartCommButtonClick(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.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.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
TrwVisionClient
    Assembly Version: 3.0.2.0
    Win32 Version: 3.0.2.0
    CodeBase: file:///C:/MyApp/MyApp.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
CommandLine
    Assembly Version: 1.9.71.2
    Win32 Version: 1.9.71.2
    CodeBase: file:///C:/MyApp/CommandLine.DLL
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
PgmDownloader
    Assembly Version: 1.0.0.8
    Win32 Version: 1.0.0.8
    CodeBase: file:///C:/MyApp/PgmDownloader.DLL
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
4ruj2ecw
    Assembly Version: 3.0.2.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
vxlapi_NET20
    Assembly Version: 8.3.4737.17695
    Win32 Version: 8.3.4737.17695
    CodeBase: file:///C:/MyApp/vxlapi_NET20.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.

Ive also attached a screenshot of the error.

Can anyone help?

Thanks

 

post-85924-0-90077600-1400054527_thumb.p

Link to comment
Share on other sites

Hi,

I think is a path dependancy.

Try to run script in the same directory of your application.

Check this:

EnvSet()

Cheers.

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

Maybe I missed it, but which version of AutoIt do you run? Which operating system? 32 or 64 bit? Did you compile the AutoIt script for 32 or 64 bit? ...

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The error you're seeing is a .NET native message box for showing exceptions in compiled programs. It's nothing related to AutoIt.

I believe that the app you're trying to start does not like being a child process. If you use ShellExecute or Run commands, then the app you're trying to start will act as a child process of the process that started it. To test this you can download Process Explorer and try to start "notepad.exe" from ShellExecute or Run. You'll notice that the "notepad.exe" is now a child process of your autoit's script.

If that is indeed the case, then this might help:
 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>

;set your app destination here:
$AppThatIWantToStart = "C:\Windows\notepad.exe"; REQUIRES FULL DESTINATION if outside of %windir%, but in this case I could have just written: "notepad.exe" because "notepad.exe" is indeed in the %windir%

$Form1 = GUICreate("Form1", 300, 100)
$Button1 = GUICtrlCreateButton("start APP", 0, 0, 300, 50)
$Button2 = GUICtrlCreateButton("start APP alternative", 0, 50, 300, 50)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            ShellExecute($AppThatIWantToStart)
        Case $Button2
            ShellExecuteNoParrent($AppThatIWantToStart, "", "/MAX");/MAX will maximize it, for other options check this link: http://ss64.com/nt/start.html
            if @error then MsgBox(0, "error", "could not start your program")
    EndSwitch
WEnd

Func ShellExecuteNoParrent($fileName, $parameters = "", $options = "", $title = "", $command = "")
    $tempFile = @TempDir & "\tempStartMyApp.bat"
    if StringLen($options) > 0 then $options = " " & $options
    $title = ' "' & $title & '"'
    if StringLen($command) > 0 then $command = ' "' & $command & '"'
    if StringLen($parameters) > 0 then $parameters = " " & $parameters
    $scriptLines = "@echo off" & @CRLF & 'START ' & $options & $title & ' "' & $fileName & '"' & $command & $parameters
    $FileHandle = FileOpen($tempFile, $FO_UTF8_NOBOM + $FO_OVERWRITE)
    if @error then Return SetError(1, 0, 0)
    FileWrite($FileHandle, $scriptLines)
    FileClose($FileHandle)
    ShellExecuteWait("tempStartMyApp.bat", Default, @TempDir, Default, @SW_HIDE)
    FileDelete($tempFile)
EndFunc

First button will start the app normally (and you can see that your app - notepad.exe, is now a child of your script), and the 2nd button will start the app as it's being started from a windows native "run" dialog box (where parent is "explorer.exe").

Link to comment
Share on other sites

  • 4 years later...

Did we have any solution which worked for this issue?

I am also facing the same issue where I am able to log in to one of the application and perform some steps  then at one point where I am trying double click on element It do the double click but I am getting the same "Unhandled Exception" dialog box

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...