0

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:

  1. Start the exe file
  2. dll form function is executed in (1)
  3. Delay 6min
  4. dll form function is executed in (1)
  5. 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?

Markus.H1
  • 31
  • 7
  • I believe you are using remoting to do some work.Please explain your situation and setup. It woruld be helpful if your could provide exception message in English. – Erdogan Kurtur Jan 18 '18 at 11:13
  • Did you include `[STAThread]` in the executable you start with? I'm not an expert on this but https://stackoverflow.com/questions/1361033/what-does-stathread-do "if it is omitted, the Windows components might not work correctly" – C.Evenhuis Jan 18 '18 at 13:43
  • The executable is a commercial program that cannot be edited. I found somewhere that this executable is not serving the InitializeLifetimeService. Is there a way to check if this is the problem? – Markus.H1 Jan 18 '18 at 15:58

0 Answers0