Home > Net >  C # Winform error System from the start. The Reflection. TargetInvocationException
C # Winform error System from the start. The Reflection. TargetInvocationException

Time:11-07

Dear leaders,

Study for a few days didn't find the reason, also ask bosses to help see,

C # winform procedure in use process without changing the program code, start to run after all of a sudden in the program. The cs program error, has been the case, after the restart the computer also useless, problems existing in the use process before using v at the same time open two names are called Pannel winform procedure, but without modification code,

The static void Main ()
{
Application.EnableVisualStyles();
Application. SetCompatibleTextRenderingDefault (false);
Application. The Run (new Pannel ()); (error)
}
}

An error screenshot:


Detailed error information is as follows:
System. Reflection. TargetInvocationException
HResult=0 x80131604
Message=Exception has had been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
Ats System. RuntimeMethodHandle. InvokeMethod (Object, target, Object [] the arguments, Signature sig, Boolean constructor)
Ats System. Reflection. RuntimeMethodInfo. UnsafeInvokeInternal (Object obj, Object [] the parameters, the Object [] the arguments)
Ats System. Delegate. DynamicInvokeImpl (Object [] args)
Ats System. Windows. Forms. Control. InvokeMarshaledCallbackDo ThreadMethodEntry (tme)
Ats System. Windows. Forms. Control. InvokeMarshaledCallbackHelper (Object obj)
Ats System. Threading. -- an optional ExecutionContext. RunInternal (-- an optional ExecutionContext -- an optional ExecutionContext, ContextCallback callback, the Object state, Boolean preserveSyncCtx)
Ats System. Threading. -- an optional ExecutionContext. Run (-- an optional ExecutionContext -- an optional ExecutionContext, ContextCallback callback, the Object state, Boolean preserveSyncCtx)
Ats System. Threading. -- an optional ExecutionContext. Run (-- an optional ExecutionContext -- an optional ExecutionContext, ContextCallback callback, the Object state)
Ats System. Windows. Forms. Control. InvokeMarshaledCallback ThreadMethodEntry (tme)
Ats System. Windows. Forms. Control. InvokeMarshaledCallbacks ()
Ats System. Windows. Forms. Control. WndProc (Message& M)
Ats System. Windows. Forms. Control. ControlNativeWindow. OnMessage (Message& M)
Ats System. Windows. Forms. Control. ControlNativeWindow. WndProc (Message& M)
Ats System. Windows. Forms. NativeWindow. DebuggableCallback (IntPtr hWnd, Int32 MSG, IntPtr wparam, IntPtr lparam)
Ats System. Windows. Forms. UnsafeNativeMethods. DispatchMessageW (MSG& MSG)
At System.Windows.Forms.Application.Com ponentManager. System. Windows. Forms. UnsafeNativeMethods. IMsoComponentManager. FPushMessageLoop (IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
Ats System. Windows. Forms. Application. ThreadContext. RunMessageLoopInner (Int32 reason, ApplicationContext context)
Ats System. Windows. Forms. Application. ThreadContext. RunMessageLoop (Int32 reason, ApplicationContext context)
Ats System. Windows. Forms. Application. The Run (Form mainForm)
At a Panel. The Program. The Main () in D: \ sgmuserprofile \ s9b5ga \ Desktop \ Test \ Panel_Upate_20201021 - ADD serial data MAX MIN AVG \ Panel \ Program cs: line 19

This exception was originally thrown at This call stack:
System. Diagnostics. Process. The Start ()
System. Diagnostics. Process. The Start (System. Diagnostics. ProcessStartInfo)
A Panel. The Pannel. Programming () in Pannel. Cs
A Panel. The Pannel. BtnStart_Click (object, System. EventArgs) in Pannel. Cs
System.Runtime.Com pilerServices. AsyncMethodBuilderCore. ThrowAsync. AnonymousMethod__6_0 (object)

The Inner Exception 1:
InvalidOperationException: always start a process because a file name from the had been provided.

CodePudding user response:

Application. The Run (new Pannel ()); This place is only a Form or a subclass of the Form, what is your the Pannel?

CodePudding user response:

reference 1st floor icoolno1 response:
Application. The Run (new Pannel ()); This place is only a Form or a subclass of the Form, what is your the Pannel?

The Pannel is Form, just change a name,

CodePudding user response:

Add the same code, on the other computer sometimes is can run, but run has been on my computer has a problem,

CodePudding user response:

To check the abnormal Settings option on don't have something ok try catch wrong place not in the form

CodePudding user response:

This exception was originally thrown at This call stack:
System. Diagnostics. Process. The Start ()
System. Diagnostics. Process. The Start (System. Diagnostics. ProcessStartInfo)
A Panel. The Pannel. Programming () in Pannel. Cs
A Panel. The Pannel. BtnStart_Click (object, System. EventArgs) in Pannel. Cs
System.Runtime.Com pilerServices. AsyncMethodBuilderCore. ThrowAsync. AnonymousMethod__6_0 (object)


If you click the button to quote wrong???????

CodePudding user response:

refer to the second floor Helloworld3020 response:
Quote: refer to 1st floor icoolno1 response:
Application. The Run (new Pannel ()); This place is only a Form or a subclass of the Form, what is your the Pannel?

The Pannel is Form, just change a name,


Button in the event start another process, but can't find the executable file,

This exception was originally thrown at This call stack:
System. Diagnostics. Process. The Start ()
System. Diagnostics. Process. The Start (System. Diagnostics. ProcessStartInfo)
A Panel. The Pannel. Programming () in Pannel. Cs
nullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related