I created a dll with C# in VisualStudio 2015 which contains only one function that displays a form with an Ok button. Then I call this dll in another program at different positions. What now happens is that if there is a long delay between the calls then I get an exception.
Example:
- Start the exe file
- dll form function is executed in (1)
- Delay 6min
- dll form function is executed in (1)
- dll form function is executed in (1)
The executions in position 2 and 4 are working, but number 5 creates this exception:
User routine threw exception with message: Object "/888e6a9f_1850_4b1a_8704_d93b028039ae/qq308tzhkm0vwywyb3j57rqn_5.rem" has been disconnected or does not exist at the server.
I found that the exeption is created in the constructor of the form which calls the automatically created function „InitializeComponent();“
In InitializeComponent is the line
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
which creates the exception.
This line is only there if I use a custom icon for the form. So if I don't use a custom icon, then this line is not there and I also don't get an exception after the 6 min delay.
My question is:
Why does this happen? Why can the dll not find the icon after the delay. The dll itself is still loaded as I get the exception message back from the called function. And also other functions in the dll which don't have a form are still working.
Does someone have an idea?