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.

GohanP
  • 399
  • 2
  • 6
  • 18
  • I'm strongly inclined to say that the code that you posted can't throw a `NullReferenceException` (unless I'm missing something?) There almost *has* to be more code than this, in at least on of the click handlers, please make sure to show us ALL the code that gets executed. – Peter B Feb 05 '19 at 12:25
  • This is a duplicate of the NRE question. The steps there must be followed to find out what's wrong. What is the *call stack* of this exception? This will show which method calls resulted in that NRE. The code posted here wouldn't throw. – Panagiotis Kanavos Feb 05 '19 at 12:58
  • `but at the same time Unhandled Exceprion is shown` Please explain how you identified **which line of code** threw the exception. – mjwills Feb 05 '19 at 12:58
  • No matter the exception, post the *full* exception text, including the call stack. You can get it easily with `Exception.ToString()`. Add proper exception handling and logging to your code and log any exceptions. You could add an [Unhandled exception handler](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.application.setunhandledexceptionmode?view=netframework-4.7.2) to log all exceptions – Panagiotis Kanavos Feb 05 '19 at 13:01
  • Given the exception is coming from `DevExpess`, I suspect you should raise a support ticket with them - https://www.devexpress.com/Support/Center/Question/ChangeFilterSet/1?FavoritesOnly=False&MyItemsOnly=True&MyTeamItemsOnly=False&PlatformName=AllPlatforms&ProductName=AllProducts&TicketType=All . – mjwills Feb 05 '19 at 20:46

0 Answers0