Problem with Building DLL after the AppDomain is unloaded.

R

Raveendra M

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.
 
J

Jerry

Ho

I have the same Problem (it not occurs every compile/start.... very
strange...)

As Workaround I restart the IIS with a Batch File:

net stop W3SVC
net stop SMTPSVC
net stop MSFTPSVC
net stop IISADMIN
net start IISADMIN
net start W3SVC
net start SMTPSVC
net start MSFTPSVC
pause

I hope someone has a better Idea..........
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top