0

I am posting this question because the existing forum references to StackOverflowException, while informative, aren't exactly relevant to the current scenario that I am encountering.

I have been developing an application for my employer that I recently created an MSI for and installed on the Company's Citrix server farm. When I launched the application via Citrix Workspace, it came up successfully. However, when I clicked on a specific button to instantiate one of the application's Windows forms, a StackOverflowException occurred. This was a surprise, as the StackOverFlowException was not being thrown on my development machine and never has. I have been developing this application for over a year.

There are three (3) servers in the Company's Citrix server farm. The StackOverFlowException occurs on two (2) of them, but not the third. I have verified this by logging into each server and running the compiled application directly.

Since debugging the error is not an option on the Citrix servers, I added dialog windows to the application code and created a modified executable which I then used on the Citrix servers in question.

Using that approach, I was able to pinpoint the statement where the exception was thrown. It was thrown at the point where form's New constructor was called:

New Constructor - Arrow

So, I looked at the code for the constructor. Placing a couple more dialog boxes in the code and rerunning the application, I was able to determine that the exception occurred during the call to InitializeComponent:

New constructor - InitializeComponent call

The Windows form in question is a very large form with a multitude of controls including several TabControls, TreeViews and multiple SplitContainers (some of which are nested).

Not surprisingly, InitializeComponent is a very large routine; too large to post in this thread; otherwise I would have done so.

I dont see any recursion within the New constructor or InitializeComponent. Moreover, what is perplexing here is why the SystemStackOverFlowException is occurring on two of the three servers but not the third.

If anyone has any ideas I would like to hear them. Any suggestions and/or insights would, of course, be greatly appreciated.

My development machine is using VS2017 (.Net Framework 4.8.1) on Windows 10.

The three (3) Citrix servers in our server farm are all on Windows 2008 Server R2. They all have .NET Frameworks 4.8.1 installed.

LarsTech
  • 80,625
  • 14
  • 153
  • 225
  • 2
    We don't like images of code at this site. Text versions please. – LarsTech May 12 '20 at 15:36
  • 1
    Sometimes event driven architectures can have event propagation loops that trigger stack overflows. Can you run the application in a debugger and print the stack trace on the overflow? That would perhaps be the easiest way to tell what's going on. – chub500 May 12 '20 at 15:42
  • Are you sure about that .NET Framework version? I cannot find anything later than 4.8 referred to anywhere. – Andrew Morton May 12 '20 at 16:34
  • @AndrewMorton I checked the Control Panel installed programs list on the Citrix servers and the .NET Frameworks installed instance displayed as .NET Framework 4.8.1. However, I imagine that the version actually is/was 4.8. – Christopher H. Fleetwood May 12 '20 at 18:45
  • @LarsTech Noted. I didn't think it would make a difference in this case as only a few lines of code were involved. Anything larger, I would have posted the code itself. – Christopher H. Fleetwood May 12 '20 at 18:46
  • @chub500 I've already considered that approach. Unfortunately, I don't have the option of debugging the executable on the Citrix server as it is a production server and, subsequently, VS cannot be put on that server. – Christopher H. Fleetwood May 12 '20 at 18:51
  • 1
    Images of code usually attracts a lot of down and close votes. If the code works on one server and not the others, it makes it extremely difficult for us to offer any help. If you really think the `InitializeComponent()` code is causing the exception, you would have to post that code for us to see it. – LarsTech May 12 '20 at 18:55
  • If it is happening in the InitializeComponent code as you suggest, could be one of the controls on you form causing the issue maybe. Do you have any 3rd party or custom controls on your form? – Hursey May 12 '20 at 20:49
  • @LarsTech Noted. I did try to post the ```InitializeComponent()``` code when submitting the original post but it's very large and exceeded the site's allowance for post size. – Christopher H. Fleetwood May 13 '20 at 22:55
  • @Hursey I do. I am using a RichTextBoxExtended control that is basically a combination of a RichTextBox control and a formatting toolbar that I found online [link]https://www.codeproject.com/Articles/868653/EXTENDED-Version-of-Extended-Rich-Text-Box-RichTex[link]. Incidentally, my ```InitializeComponent()``` routine is 2800+ lines (it's a large, complex form( – Christopher H. Fleetwood May 13 '20 at 23:23
  • Are you able to remove that for a test? – Hursey May 13 '20 at 23:25
  • @Hursey I can. I'll give it a try and see what happens. – Christopher H. Fleetwood May 13 '20 at 23:33
  • No idea if that's the problem, but in your situation that's where I would start. Possible something in there is what's causing your stack overflow, perhaps some your deployment servers are a little more tolerant than the others. And as a general comment, I've been caught out in the past downloading add-ons from code project not quite being fit for purpose. Much more reliable I've found to use nugets and/or forking git repos – Hursey May 13 '20 at 23:44
  • @Hursey I replaced the custom control with a standard RichTextBox, recreated the executable and tried to instantiate the form in question. The same ```SystemStackOverflowException``` occurred. – Christopher H. Fleetwood May 14 '20 at 00:19
  • @Hursey You mentioned about some deployment servers being a little more tolerant than others? Could you elaborate on that? Is it possible that there is some server setting that might not be the same for all the servers? Perhaps there is some adjustment that could be made server-side? – Christopher H. Fleetwood May 14 '20 at 00:22
  • Sorry, a little out of my area. What you could try is remove 1 component from your form at a time. Years ago I had a situation where I had too many controls on a form (I was dynamically making controls, but it was thousands), and one production out of a dozen PC started giving me weird errors about GDI stacks. is it possible that's what you've hit? – Hursey May 14 '20 at 00:30
  • @Hursey If it is, then I'm in for it. The form in question is completely developed and every control is tightly integrated. There are hundreds of them and at least twice as many references, Removing them one at a time and testing by trial and error will be a... I realize I'm "preaching to the choir", of course... – Christopher H. Fleetwood May 14 '20 at 00:49
  • @Hursey Since changing an established form structure was definitely not the way I wanted to go, I did a little research "server-side" and found that the virtual memory (paging file) size on each of the Citrix servers was way below the recommended setting for the OS (Windows 2008 Server R2). This could be the reason for the ```SystemStackOverflowException```. I'm going to increase the paging file size on each of the servers and see if that resolves the issue. – Christopher H. Fleetwood May 15 '20 at 15:49

0 Answers0