Process.Start() causes unhanded exception but not always

0

In my aplication I have one event which have hardcoded some jira query and then create new process with this query as argument (the query is hidden in the sample below, but it works fine):

private void recentPinItem_submitBug_ItemClick(object sender, RecentItemEventArgs e)
    { 
      var jiraQuery = "http://jiraprod1.xxx";
      Process.Start(jiraQuery);
    }

This event is assigned to two different recentPinItems (recentPinItems1 and recentPinItem2 - they are on different backstageviewcontrols).

What is the problem:

  1. On recentPinItem1 click this event works fine. Browser with jira and proper query is opened and the application is still running - OK

  2. On recentPinItem2 click there is an error. Browser with jira is opened but at the same time Unhandled Exceprion is shown (NullReferenceException). When continue, an application works fine.

What I observed: this event works always fine for recentPinItem1 this event works sometimes fine for recentPinItem2, but most of the time there is an error described above.

Do you have any idea what can cause this behaviour? I've tried with:

  Process.Start(new ProcessStartInfo
  {
    FileName = jiraQuery,
    Arguments = "",
    UseShellExecute = true
  });

and also with UseShellExecute = false but it also didnt help

EDIT: this is not duplicate of the wuestiopn "what is the nullreferenceexception" what is suggested. I know what does this exception means. I do not know why it is showing in this case when it shouldn't

EDIT2: More details: There is no more code related with this event. What I have already done:

  1. I have put a breakpoint on line var jiraQuery = "http://jiraprod1.xxx";
  2. F10
  3. Application goes to "Program.cs" and to line Application.Run(MainView). Exception Unhandled is raised in this moment. Details of excpetion:

System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object.
Source=DevExpress.XtraBars.v18.1 StackTrace: at DevExpress.XtraBars.Ribbon.Handler.RecentControlHandler.OnMouseDown(DXMouseEventArgs ee) at DevExpress.XtraBars.Ribbon.RecentItemControl.OnMouseDown(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at DevExpress.Utils.Controls.ControlBase.WndProc(Message& m) at DevExpress.XtraEditors.BaseControl.WndProc(Message& msg) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at TesterEssentials.Program.Main(String[] args) in C:\99999099_TCK_ITV_EC_BODY_FAS-903_Test_Editor\XMLGen\TestScriptGenerator\Program.cs:line 61

What is more, I make workaround and create a new thread:

  Application.DoEvents();
  new Thread(delegate ()
  {
    Thread.CurrentThread.IsBackground = true;
    Process.Start(new ProcessStartInfo
    {
      FileName = jiraQuery,
      Arguments = "",
      UseShellExecute = true
    });
  }).Start();
  Application.DoEvents();

and now this error disappear.

c#
process.start
asked on Stack Overflow Feb 5, 2019 by GohanP • edited Feb 5, 2019 by GohanP

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0