Home > Net >  Exe files in the c # Winform programming Debug folder separate execution times wrong, but when VS en
Exe files in the c # Winform programming Debug folder separate execution times wrong, but when VS en

Time:12-23

Dear leaders,

Small white ability is limited, not understand VS environment where in the world the difference between debugging and running exe file directly, in this more than a week, also look at the bosses, please help, do not appreciate,

Problem description: in this paper, through the method of UIA wrote a c # Winform procedure, some of the functionality is by writing program calls another computer software UI controls, automation, click on the button to select the function such as file input, click start debugging in VS2019 environment without error, but from the debug folder to pull out your exe files separate runtime discovery program error (occasionally with luck will not an error), through found in Winform interface text output is on to find the computer is called the window of the program interface not found error,

Error code:
Private void GetEcuInfo (String EcuAddress)
{
AutomationElement formDPS=null;
//AutomationElement formProgramming=null;
AutomationElement formSelectJ2534=null;
AutomationElement formGCIErrorTip=null;
AutomationElement NoVINTip=null;
AutomationElement formSecurityFacility=null;
AutomationElement formEcuInfo=null;
String successTip=null;

AutomationElement root=AutomationElement. RootElement;

AutomationElementCollection coll=root. The.findall (TreeScope. Children, new
PropertyCondition (AutomationElement ControlTypeProperty ControlType. Windows));
Txt_Status. AppendText (" Start find DPS window "+" \ r \ n "); (exe file to run when the output after Start find DPS Windows error)

For (int numWait=0; FormDPS==null & amp; & NumWait & lt; 500; NumWait++)
{
Foreach (AutomationElement I in coll)
{
String name1=(string) (i.G etCurrentPropertyValue (AutomationElement. NameProperty));
If (name1. The Contains (" Development Programming System "))
//because the name of the first layer window open after the child window will "Development Programming System - Programming", so here by naming the containment relationship lookup
{
FormDPS=I;
Console. WriteLine (formDPS. GetCurrentPropertyValue (AutomationElement. NameProperty) + "for GCI");
}
}
}


Exe file to run an error screenshot as shown below:



Above error detailed information is as follows:
See the end of this message for the details on invoking
Just - in - time (JIT) home was debugging this dialog box.

* * * * * * * * * * * * * * Exception Text * * * * * * * * * * * * * *
System. Windows. Automation. ElementNotAvailableException: The target element corresponds to The UI that is no longer available (for example, The parent window has closed).
The at MS. Internal. AutomationProxies. Misc. ThrowWin32ExceptionsIfError (Int32 errorCode)
The at MS. Internal. AutomationProxies. Misc. GetClassName (IntPtr HWND)
The at MS. Internal. AutomationProxies. WindowsFormsHelper. IsWindowsFormsControl (IntPtr HWND, FormControlState& State)
The at MS. Internal. AutomationProxies. ProxyHwnd. GetElementProperty (AutomationProperty idProp)
The at MS. Internal. AutomationProxies. ProxySimple. System. Windows. Automation. The Provider. IRawElementProviderSimple. GetPropertyValue (Int32 propertyId)
The at MS. Internal. Automation. UiaCoreApi. CheckError (Int32 hr)
Ats System. Windows. Automation. AutomationElement. GetCurrentPropertyValue (AutomationProperty property, Boolean ignoreDefaultValue)
Ats System. Windows. Automation. AutomationElement. GetCurrentPropertyValue (AutomationProperty property)
At a Panel. The Pannel. GetEcuInfo (String EcuAddress)
At a Panel. The Pannel. Programming ()
At a Panel. The Pannel. & lt; BtnStart_Click & gt; D__47. MoveNext ()
- the End of the stack trace from previous location where the exception was thrown -- -- --
At System.Runtime.Com pilerServices. AsyncMethodBuilderCore. & lt;> C. & lt; ThrowAsync> B__6_0 (Object state)


* * * * * * * * * * * * * * the Loaded Assemblies * * * * * * * * * * * * * *
Mscorlib
The Assembly Version: 4.0.0.0
Win32 Version: 4.8.4180.0 built by: NET48REL1LAST_B
The CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The Panel
The Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
The CodeBase: file:///D:/sgmuserprofile/s9b5ga/Desktop/Panel.exe
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
System. Windows. Forms
The Assembly Version: 4.0.0.0
Win32 Version: 4.8.4180.0 built by: NET48REL1LAST_B
The CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The System
The Assembly Version: 4.0.0.0
Win32 Version: 4.8.4001.0 built by: NET48REL1LAST_C
The CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
System. Drawing
The Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
The CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
System. The Configuration
The Assembly Version: 4.0.0.0
Win32 Version: 4.8.3761.0 built by: NET48REL1
The CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related