“Object has been disconnected or does not exist at the server” exception

后端 未结 7 815
孤街浪徒
孤街浪徒 2020-12-04 19:31

I need to use cross-appdomain calls in my app, and sometimes I have this RemotingException:

Object \'/2fa53226_da41_42ba_b185_ec7d9c454712/ygiw+xfegmk

7条回答
  •  攒了一身酷
    2020-12-04 19:46

    This happened for us because we had a static variable in one of our classes that was of type AppDomain. The class was used in a long running windows service. AppDomain has a InitializeLifetimeService method that needs to be overridden like this:

    public override object InitializeLifetimeService(){
        return null;
    }
    

    We were constantly using this as the private variable that loaded and unloaded some dlls for custom built outside logic. The answer has been taken from here: msdn answer

    Because we were not able to change this at production time, we ended with a compromise of restarting the windows service at random intervals that are shorter than the lifetime of the static AppDomain variable which by trial and error we found that it is several days.

    This question also helped clarify some things about lifetime: stackoverflow-question

提交回复
热议问题