winforms - ISessionFactory object thru Appdomain bondaries -


(i'm little hopeless question, since haven't found article pointing want).

anyways:

is there way share single isessionfactory (sessionfactoryimpl) between multiple appdomains?

-- or --

is possible spawn isessions isessionfactory , serialize new created isession different appdomain?

-- or --

in winforms-based application, success story isessionfactory / isession management, regarding startup times , memory consumption?

the long story (for prefer details):

  • my application erp winforms based , can spawns multiple 'sub-applications' (forms);
  • each sub-application have own assembly, can updated independently;
  • spawning new appdomain great isolate static members of each 'sub-application'. when application finished, sub-program appdomain resources unloaded well. did while, since sessionfactory costly (in time , in memory), model started become untenable (for now, using threads , threadstatic members hold particular information of each sub-app);
  • we pretty propped on lazy-loading, can't give feature also.

what have tried:

  • marshalbyref class shares isessionfactory: couldn't work (can't remember why), serializing isessionfactory cause duplication of memory (a big amount) anyways. right?
  • marshalbyref class spawns isession , serialize other appdomain: since isession holds properties on parent isessionfactory, in other boundaries, brought me nice expcetions telling me properties not defined.

my success story winforms app serialize configuration first time application run , serialized file loaded on subsequent runs. reduces application startup time. might possible distribute application serialized configuration eliminate lag on first run.

the serialization looks this:

    private const string serialized_config = "configuration.bin";      private configuration getconfiguration()          configuration config = null;         config = loadconfigurationfromfile();          if (config == null)         {             // create new configuration, code omitted             config = fluentconfig.buildconfiguration();                         saveconfigurationtofile(config);         }     }      private configuration loadconfigurationfromfile()     {         try         {             if (!isconfigurationfilevalid())             {                 return null;             }              using (var file = file.open(serialized_config, filemode.open))             {                 var bf = new binaryformatter();                 return bf.deserialize(file) configuration;             }         }         catch (exception ex)         {             return null;         }     }      private bool isconfigurationfilevalid()     {         if (!file.exists(serialized_config))         {             return false;         }          var configinfo = new fileinfo(serialized_config);          // assumes assemblies in same location , written @ same time         var asm = _assemblies.first();         var asminfo = new fileinfo(asm.location);          if (asminfo.lastwritetime > configinfo.lastwritetime)         {             return false;         }         return true;     }      private void saveconfigurationtofile(configuration config)     {          using (var file = file.open(serialized_config, filemode.create))         {             var bf = new binaryformatter();             bf.serialize(file, config);         }     } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -