It is not allowing build the DLL after unloading the AppDomain

From: Raveendra M (raveendra_m_at_hotmail.com)
Date: 07/28/03


Date: Sun, 27 Jul 2003 23:43:16 -0700


Hi!
I am working with ASP.NET application. In my page I am
creating one Application Domain and in that domain I am
calling my DLL. Using the methods of the dll. And
unloading the Application Domain. Till this point it is
working fine.
My problem is, while web page is open, than I am modifying
the dll, and rebuilding. Then it is giving error:
"The file 'MyClass.dll' cannot be copied to the run
directory. The process cannot access the file because it
is being used by another process."

How do I over come this problem?

My ASPX page code is :
==========================================================
private void Page_Load(object sender, System.EventArgs e)
{
        InitMethod();
}
private void InitMethod()
                {
                        AppDomainSetup info = new
AppDomainSetup();
                        info.ApplicationBase = "file:///"
+ System.Environment.CurrentDirectory;
                        // Create an application domain
with null evidence
                        AppDomain dom =
AppDomain.CreateDomain("RemoteDomain", null, info);
                        // Tell the AppDomain to execute
the assembly
                        System.Reflection.Assembly a =
System.Reflection.Assembly.LoadFrom
("D:\\Raveendra\\APPDomain\\MyClass\\bin\\Debug\\MyClass.dl
l");
                        object o = a.CreateInstance
("MyClass.Class1",
                                false,
                        
        System.Reflection.BindingFlags.Public |
                        
        System.Reflection.BindingFlags.Instance |
                        
        System.Reflection.BindingFlags.InvokeMethod,
                                null,
                                null,
        
                                null,
                                null);

                        System.Type t = o.GetType ();

                        Object result = t.InvokeMember
( "FindSum",
                        
        System.Reflection.BindingFlags.Public |
                        
        System.Reflection.BindingFlags.Instance |
                        
        System.Reflection.BindingFlags.InvokeMethod ,
                                null, o, new object [] {});

                        Response.Write (result);
                        //Call a method with arguments
                        object [] args = new object []
{100, 184};
                        
                        Object result1 = t.InvokeMember
( "FindSum1",
                        
        System.Reflection.BindingFlags.Public |
                        
        System.Reflection.BindingFlags.Instance |
                        
        System.Reflection.BindingFlags.InvokeMethod ,
                                null, o, args);
                        TextBox1.Text = result1.ToString
() ;
                        AppDomain.Unload(dom);
                }

==========================================================
In brief my problem is :
when the try to build the Dll in the
path "D:\\Raveendra\\APPDomain\\MyClass\\bin\\Debug\\MyClas
s.dll", while ASP.NET page is running, it is not allowing
me. How to over come this problem, with out stoping the
IIS?

Thanks for your help.



Relevant Pages

  • Re: BackgroundWorker not working...
    ... > private void mBW_RunWorkerCompleted(object sender, ... > private void mBW_ProgressChanged(object sender, ... >> using types from the namespacein the said dll. ... >>>[Der Typ oder Namespace 'BackgroundWorker' konnte nicht gefunden werden. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Remote application only works in dll (assemblies) are also installed on locally.
    ... >From this you are using a Reference to the DLL and so if you simply delete ... the DLL you will most definitely get this error. ... > think the string return by the function is serializable. ... > private void InitializeComponent() ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Accessing Unmanaged code from ASP.net
    ... Try to put this dll into the same folder where .net assembly you're ... p/invoking from is located. ... > private void SendCmd ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Non-dotnet DLLs: brick wall hit
    ... I've written a silly little Delphi DLL which works the ... struct ToutData ... private void btnTest_Click ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: assembly security/permission question
    ... in the assembly of a DLL, and that DLL has an event other DLLs subscribe to ... > public class TestClass ... > public OpenFileDialog openFileDialog1 = new OpenFileDialog; ... > private void button1_Click ...
    (microsoft.public.dotnet.framework)