AppDomains and Dynaimc Loading problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JonS.

    AppDomains and Dynaimc Loading problem

    Hi,

    I posted this article (
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

    ) last week, and have yet to receive any replies. If someone could please
    give me further information I would greatly appreciate it.

    Sincerely,

    Jon
  • Dmitriy Lapshin [C# / .NET MVP]

    #2
    Re: AppDomains and Dynaimc Loading problem

    Hi,

    I remember there are two solutions:

    a) Playing with AppDomainSetup and AppDomain properties to ensure proper
    values of PrivateBinPath and other properties used by the Fusion assembly
    loader to locate assemblies.

    b) Attaching a handler to the AssemblyResolve event and loading a requested
    assembly with Assembly.LoadFr om from a known location.

    --
    Sincerely,
    Dmitriy Lapshin [C# / .NET MVP]
    Bring the power of unit testing to the VS .NET IDE today!


    "JonS." <JonS@discussio ns.microsoft.co m> wrote in message
    news:62FD5FEE-82A1-4E37-BB36-1F5C2149E5C1@mi crosoft.com...[color=blue]
    > Hi,
    >
    > I posted this article (
    > http://msdn.microsoft.com/newsgroups...aea&sloc=en-us
    > ) last week, and have yet to receive any replies. If someone could please
    > give me further information I would greatly appreciate it.
    >
    > Sincerely,
    >
    > Jon[/color]

    Comment

    • JonS.

      #3
      Re: AppDomains and Dynaimc Loading problem

      Hey Dmitriy,

      I've been working with your first solution idea. The problem is, as I
      belive I stated in the first post, it seems to me that even though I'm
      unwrapping the loader in the new appdomain the remote loader, when I use the
      AppDomain.Curre ntDomain.BasePa th it returns the base path of the AppDomain
      the main application is running in, and not the new AppDomain I created the
      loader in. Also, when I force load the path into the loader it returns a
      serialization error stating that it doesn't have enough information or some
      such.

      Again, this is just driving my crazy trying to figure it out.

      Sincerely,

      Jon

      "Dmitriy Lapshin [C# / .NET MVP]" wrote:
      [color=blue]
      > Hi,
      >
      > I remember there are two solutions:
      >
      > a) Playing with AppDomainSetup and AppDomain properties to ensure proper
      > values of PrivateBinPath and other properties used by the Fusion assembly
      > loader to locate assemblies.
      >
      > b) Attaching a handler to the AssemblyResolve event and loading a requested
      > assembly with Assembly.LoadFr om from a known location.
      >
      > --
      > Sincerely,
      > Dmitriy Lapshin [C# / .NET MVP]
      > Bring the power of unit testing to the VS .NET IDE today!
      > http://www.x-unity.net/teststudio.aspx
      >
      > "JonS." <JonS@discussio ns.microsoft.co m> wrote in message
      > news:62FD5FEE-82A1-4E37-BB36-1F5C2149E5C1@mi crosoft.com...[color=green]
      > > Hi,
      > >
      > > I posted this article (
      > > http://msdn.microsoft.com/newsgroups...aea&sloc=en-us
      > > ) last week, and have yet to receive any replies. If someone could please
      > > give me further information I would greatly appreciate it.
      > >
      > > Sincerely,
      > >
      > > Jon[/color]
      >
      >[/color]

      Comment

      • Dmitriy Lapshin [C# / .NET MVP]

        #4
        Re: AppDomains and Dynaimc Loading problem

        Jon,

        As far as I remember, when you load an assembly to an AppDomain, you have to
        load all referenced assemblies as well. Handling the AssemblyResolve event
        really helps in troubleshooting such problems, and this is the approach I'd
        recommend you tried.

        --
        Sincerely,
        Dmitriy Lapshin [C# / .NET MVP]
        Bring the power of unit testing to the VS .NET IDE today!


        "JonS." <JonS@discussio ns.microsoft.co m> wrote in message
        news:62A2C46E-C13B-4814-B56D-0338346A27ED@mi crosoft.com...[color=blue]
        > Hey Dmitriy,
        >
        > I've been working with your first solution idea. The problem is, as I
        > belive I stated in the first post, it seems to me that even though I'm
        > unwrapping the loader in the new appdomain the remote loader, when I use
        > the
        > AppDomain.Curre ntDomain.BasePa th it returns the base path of the AppDomain
        > the main application is running in, and not the new AppDomain I created
        > the
        > loader in. Also, when I force load the path into the loader it returns a
        > serialization error stating that it doesn't have enough information or
        > some
        > such.
        >
        > Again, this is just driving my crazy trying to figure it out.
        >
        > Sincerely,
        >
        > Jon
        >
        > "Dmitriy Lapshin [C# / .NET MVP]" wrote:
        >[color=green]
        >> Hi,
        >>
        >> I remember there are two solutions:
        >>
        >> a) Playing with AppDomainSetup and AppDomain properties to ensure proper
        >> values of PrivateBinPath and other properties used by the Fusion assembly
        >> loader to locate assemblies.
        >>
        >> b) Attaching a handler to the AssemblyResolve event and loading a
        >> requested
        >> assembly with Assembly.LoadFr om from a known location.
        >>
        >> --
        >> Sincerely,
        >> Dmitriy Lapshin [C# / .NET MVP]
        >> Bring the power of unit testing to the VS .NET IDE today!
        >> http://www.x-unity.net/teststudio.aspx
        >>
        >> "JonS." <JonS@discussio ns.microsoft.co m> wrote in message
        >> news:62FD5FEE-82A1-4E37-BB36-1F5C2149E5C1@mi crosoft.com...[color=darkred]
        >> > Hi,
        >> >
        >> > I posted this article (
        >> > http://msdn.microsoft.com/newsgroups...aea&sloc=en-us
        >> > ) last week, and have yet to receive any replies. If someone could
        >> > please
        >> > give me further information I would greatly appreciate it.
        >> >
        >> > Sincerely,
        >> >
        >> > Jon[/color]
        >>
        >>[/color][/color]

        Comment

        • JonS.

          #5
          RE: AppDomains and Dynaimc Loading problem

          I've found the answer to this, and most other dynamic loading and unloading
          problems at the following location:



          I know I'm not the only one who would have these problems, which is why I'm
          so surprised to find so little information on it. Anyways, please let me
          know if there are any further questions.

          Sincerely,

          Jon

          "JonS." wrote:
          [color=blue]
          > Hi,
          >
          > I posted this article (
          > http://msdn.microsoft.com/newsgroups...aea&sloc=en-us
          > ) last week, and have yet to receive any replies. If someone could please
          > give me further information I would greatly appreciate it.
          >
          > Sincerely,
          >
          > Jon[/color]

          Comment

          • Colin Stutley

            #6
            Re: AppDomains and Dynaimc Loading problem

            If the base directory of your new domain is not a sub-directory of the
            existing domain then you will have problems with this code "as is", but it
            should give you the pointers you need [no pun]. The problem with this is
            that the loader class needs to be accessible from both assemblies, and it
            also has the issue that is a 'dll' is located in both the main directory and
            the sub-directory then the main one will load first (yeah, should not
            happen, but I have seen users drag copies of old files all over the place).

            Did'nt see you post until now - but if you are still getting stuck continue
            the thread as I will put a watch point against it.
            Not an expert by no means, but ...

            - Colin.

            "JonS." <JonS@discussio ns.microsoft.co m> wrote in message
            news:B11CC66A-AEF4-4759-83D0-8FC28F2A1B74@mi crosoft.com...[color=blue]
            > I've found the answer to this, and most other dynamic loading and[/color]
            unloading[color=blue]
            > problems at the following location:
            >
            > http://www.codeproject.com/csharp/Dy...sp#xx1025463xx
            >
            > I know I'm not the only one who would have these problems, which is why[/color]
            I'm[color=blue]
            > so surprised to find so little information on it. Anyways, please let me
            > know if there are any further questions.
            >
            > Sincerely,
            >
            > Jon
            >
            > "JonS." wrote:
            >[color=green]
            > > Hi,
            > >
            > > I posted this article (
            > >[/color][/color]
            http://msdn.microsoft.com/newsgroups...aea&sloc=en-us[color=blue][color=green]
            > > ) last week, and have yet to receive any replies. If someone could[/color][/color]
            please[color=blue][color=green]
            > > give me further information I would greatly appreciate it.
            > >
            > > Sincerely,
            > >
            > > Jon[/color][/color]


            Comment

            Working...