Solved

how to use AppDomain.CreateDomain with AssemblyResolve?

Posted on 2012-03-15
4
564 Views
Last Modified: 2012-04-08
i want to load My Assemblies from wcf by using Memory. Every thing is working good WHEN:
   AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
        Assembly[] assBefore = AppDomain.CurrentDomain.GetAssemblies();
        foreach (byte[] binary in deCompressBinaries)
            loadedAssembly = AppDomain.CurrentDomain.Load(binary);

Open in new window


but i want to use AppDomain.CreateDomain not current domain:
     protected void LoadApplication()
    {
        this.ApplicationHost = AppDomain.CreateDomain("TestService", null, new AppDomainSetup
        {
            ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase
        });

        ApplicationHost.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolve);
        foreach (AssemblyName asmbly in System.Reflection.Assembly.GetExecutingAssembly().GetReferencedAssemblies())
        {
            ApplicationHost.Load(asmbly);
        }
        List<byte[]> deCompressBinaries = new List<byte[]>();
        foreach (var item in AppPackage.Item.AssemblyPackage)
            deCompressBinaries.Add(item.Buffer);
        var decompressvalues =  DeCompress(deCompressBinaries);
        deCompressBinaries.Clear();
        deCompressBinaries = decompressvalues.ToList();

        foreach (byte[] binary in deCompressBinaries)
            ApplicationHost.Load(binary);

        Assembly[] assAfter = AppDomain.CurrentDomain.GetAssemblies();
    }
   Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
    {
        return Assembly.Load(args.Name);
    }

Open in new window

i have 2 ClassLibraries. ClassLibrary1 and ClassLibrary2 using below:
    namespace ClassLibrary2
{
    public class Class1 : MarshalByRefObject
    {
        public Class1()
        {

        }

        public int GetSum(int a , int b)
        {
            try
            {
                ClassLibrary1.Class1 ctx = new ClassLibrary1.Class1();
                return ctx.Sum(a, b);
            }
            catch
            {
                return -1;
            }

        }
        public int GetMultiply(int a, int b)
        {
            return a * b;
        }
    }
}

Open in new window

Classlibrary2 depends on ClassLibrary1. So i am using assemblyresolver. But Error on ApplicationHost.Load(binary);

Error: Could not load file or assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Also NOT FIRING ASSEMBLYRESOLVER. ny cursor is not goin to Assemblyresolver method. How to use AppDomain.CreateDomain with resolve method?
0
Comment
Question by:programmerist
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Accepted Solution

by:
programmerist earned 0 total points
ID: 37728225
why dont experts answer my questions? i spend money . i want to see value for my money.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37729001
Well, I can give it a go.  Let me say that sometimes, people are disinterested, or don't want to have to dig through a lot of detailed words, code dumps, etc.  I prefer not to have too much information up front, as it only clouds the question, and makes it difficult to understand your problem enough to help.

(Getting down off my "soap box" now)...

Have you looked into Fusion log, which helps with assembly binding issues?

Fuslogvw.exe (Assembly Binding Log Viewer)
http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.100).aspx
0
 

Author Comment

by:programmerist
ID: 37746911
@TheLearhedOne: thanks alot! but if you lokk my question title . my request is too simple. look this link . what is the diffuculty of look this ques.

is it too complex?
0
 

Author Closing Comment

by:programmerist
ID: 37820799
you are too boring!!!!!!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question