Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. AppDomain scopes

AppDomain scopes

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Den2Fly
    wrote on last edited by
    #1

    Hi buddies, Suppose we have created an AppDomain with FriendlyName "NewDomain" in the current AppDomain named "CurrentDomain" and have created an instance of class A in that, now we call some method of that instance, Here is the code: AppDomainSetup domainSetup = new AppDomainSetup(); domainSetup.ApplicationBase = @"c:\myApp"; domainSetup.ShadowCopyDirectories = @"c:\myApp"; domainSetup.LoaderOptimization = LoaderOptimization.SingleDomain; AppDomain appDomain = AppDomain.CreateDomain("NewDomain", null, domainSetup); // Here the constructor is called in the 'NewDomain' domain A obj = (A)appDomain.CreateInstanceAndUnwrap(assemblyName, "A"); // Here the 'MyMethod' is called in the current application domain obj.MyMethod(); While tracing "AppDomain.CurrentDomain.FriendlyName" in class A, I see: 1. In its constructor scope, it is "NewDomain", that is ok 2. In the called method scope, it is "CurrentDomain". It means that the method is called in the 'CurrentDomain', while I wana the method be called in the "NewDomain" application domain. How can I perform it ? Thanks --- "Art happens when you least expect it."

    A 1 Reply Last reply
    0
    • D Den2Fly

      Hi buddies, Suppose we have created an AppDomain with FriendlyName "NewDomain" in the current AppDomain named "CurrentDomain" and have created an instance of class A in that, now we call some method of that instance, Here is the code: AppDomainSetup domainSetup = new AppDomainSetup(); domainSetup.ApplicationBase = @"c:\myApp"; domainSetup.ShadowCopyDirectories = @"c:\myApp"; domainSetup.LoaderOptimization = LoaderOptimization.SingleDomain; AppDomain appDomain = AppDomain.CreateDomain("NewDomain", null, domainSetup); // Here the constructor is called in the 'NewDomain' domain A obj = (A)appDomain.CreateInstanceAndUnwrap(assemblyName, "A"); // Here the 'MyMethod' is called in the current application domain obj.MyMethod(); While tracing "AppDomain.CurrentDomain.FriendlyName" in class A, I see: 1. In its constructor scope, it is "NewDomain", that is ok 2. In the called method scope, it is "CurrentDomain". It means that the method is called in the 'CurrentDomain', while I wana the method be called in the "NewDomain" application domain. How can I perform it ? Thanks --- "Art happens when you least expect it."

      A Offline
      A Offline
      Andy Brummer
      wrote on last edited by
      #2

      Make sure that A derives from MarshalByRefObject and isn't just serializable.


      I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

      D 1 Reply Last reply
      0
      • A Andy Brummer

        Make sure that A derives from MarshalByRefObject and isn't just serializable.


        I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

        D Offline
        D Offline
        Den2Fly
        wrote on last edited by
        #3

        Yes, that solved it, Thank you Andy very much :-) --- "Art happens when you least expect it."

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups