Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / July 2005

Tip: Looking for answers? Try searching our database.

Main loads AppDomain loads AppDomain *@^*%&!*

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Conroy - 08 Jul 2005 03:44 GMT
Rick Stahl puts it better than me, but we have the same issue.  

http://west-wind.com/weblog/posts/1358.aspx

"The failure occurs only when trying to load an assembly into a new
AppDomain and then only if the assembly does not exist in the parent
application's AppBase or other Bin/Probing paths. Although the AppDomain is
configured to have it’s ApplicationBase in a different directory than the
EXE’s base, the remote AppDomain CreateInstance call doesn’t apparently
doesn’t use this path, instead using the current domains ApplicationBase."

Here's the *desired* architecture:

\
|  MainApp.exe
+-Applications
  +---- Addin1
          |--- Addin1.dll
  +---- Addin2
          |--- Addin2.dll

Thus far, I can get MainApp.exe to load the Addin1.dll and Addin2.dll
assemblies.  As they are add-ins, I'm fine with them loading into MainApp's
domain.  But Addin1.dll attempts to create a separate AppDomain.  All goes
well, including the bind (Fusion logs clean), but when I try to Unwrap, I
can't get the cast.  If I move Addin1.dll to \, I'm all set.  I'm trying to
avoid that because I'd like to constrain everything Addin1 needs to its own
directory.

Has anybody solved this type of issue?  I don't know if the whole
AssemblyResolve thing would work...  Frankly, I've learned WAY more about
AppDomains in the past week than I ever wanted to know.  Although I still
have far to go, on the whole, I'd really rather be back in Kansas with Auntie
Em.

Cheers,
M.
Jim - 08 Jul 2005 16:04 GMT
Michael,

 I've built a program very similar before to the one you've described
and run into a similar issue.  The basic problem that I ran into is
that when loading Addin1, it requires some types in other assemblies
that I assumed would get loaded into the new AppDomain, but this was
not the case, and it would basically fail.  The best way to debug this
is to put a debug statement into the AssemblyResolve event in the new
appdomain.  However, keep in mind that your assembly that contains the
handler has to be in newAppDomain, and not the default AppDomain.  I
hope this makes sense.  For an example of this, see the same code on
one of my articles:
http://www.codeproject.com/csharp/Run_Code_Remotely.asp

Hope this helps,

 Jim Wiese
Michael Conroy - 22 Jul 2005 16:42 GMT
Jim,

Sorry it took so long to respond.  Thank you for your guidance.  I
downloaded the CodeProject project and looked through it, but I don't think
it quite covers the same situation.  I managed to get the Main app to load
the DLL from an alternate location than the same directory, but when that DLL
tries to create another appDomain, it just can't work out the paths.  I think
when the DLL is absorbed by the main app, it loses its reference to its
original path.

Anyway, I punted.  All DLLs now live in the same directory and each DLL has
its own separate "helper" directory - the directory I'd originally hoped to
locate the DLL itself.  It isn't pretty, but it'll let me keep working.  

Thanks for trying...

:)
M.

> Michael,
>
[quoted text clipped - 13 lines]
>
>   Jim Wiese

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.