Loading an embedded assembly from another embedded assembly into the executing assembly

I have a custom code library (.dll) where I store controls and shared procedures that I’ve written. Two of the controls in my library reference a 3rd party .net assembly (.dll).
      Using my custom library, I have another assembly (.exe). Currently I have my custom library added as a resource to my exe, and I load it using the AssemblyResolve event as shown below:
    Public Sub New() ‘The constructor for the main form in my exe

        AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf Domain_AssembilyResolve


        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        ...
    End Sub

    Private Function Domain_AssembilyResolve(sender As Object, args As System.ResolveEventArgs) As System.Reflection.Assembly
        If InStr(args.Name, "MyLibrary") Then Return Assembly.Load(My.Resources.MyLibrary)
        Return Nothing
    End Function

Open in new window

     The problem comes in here. I want to load the 3rd party dll along with mine, without having to add it as a resource to my main executable. In other words, I want to embed the 3rd party dll in my custom library import them both.
      The reason for this is that if I don’t do it this way, I’ll have to embed the 3rd party dll in any project which uses my dll. This isn’t crustal just convenient. Can it be done?
BROOKLYN1950Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
This sounds like a cross-domain proxy is where you should look:

Fast Marshaling for Cross-AppDomain Proxies
http://www.codeproject.com/Articles/35851/Fast-Marshaling-for-Cross-AppDomain-Proxies
0
BROOKLYN1950Author Commented:
I'm not very familiar with AppDomains (though I bet I will be after this), so I can't tell if this is what I need or not. Either way, the code there is closed-source so I wouldn't be able to use it anyway.
0
Bob LearnedCommented:
That CodeProject article was meant to highlight the concept of cross-domain calls.

Here is blog entry that describes the concept:

Executing Code in Another AppDomain
http://blogs.msdn.com/b/suzcook/archive/2003/06/12/executing-code-in-another-appdomain.aspx

"Be sure to not pass any Type/Assembly/etc. instances (besides your MarshalByRefObject type) back to the original appdomain. If you do, it will cause those assemblies to be loaded into the original appdomain."

If you need to export any types, then cross-AppDomain would not be a good choice.
0
BROOKLYN1950Author Commented:
I figured out that as long as I don't call any classes that reference the 3rd party DLL it doesn't have to be loaded (which should have been obvious), so I only need to include it in projects which reference those classes. This is something I can live with.

As for 'Cross-domain proxies', they seem a little bit over my head at the moment, so unless someone else has some extremely simple idea (which I doubt) I think I'll just drop this one.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BROOKLYN1950Author Commented:
See the post as to why it is the answer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.