Ask a Question related to ASP.NET General, Design and Development.
-
Raveendra M #1
Problem with Building DLL after the AppDomain is unloaded.
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\\M yClass.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\\My Clas
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.
Raveendra M Guest
-
Appliation unloaded!!!
Hi, I'm looking for a way to detect when an user leaves a flex application. I want to be able to make an action when an user closes the browser,... -
AppDomain.UnhandledException dose note fired
Hi All I use following code to register event handler protected void Application_Start(Object sender, EventArgs e) {... -
Appdomain unloded under IIS 5.0
My application, which is a hand-coded HttpModule (not created with Visual Studio.NET) is acting inconsistently on different machines. I have a unit... -
It is not allowing build the DLL after unloading the AppDomain
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... -
Is there a way to unload the current appdomain?
If I have two applications that are side by side they both use the same instance of the aspnet_wp.exe. How can I unload one of these applications... -
Jerry #2
Re: Problem with Building DLL after the AppDomain is unloaded.
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..........
"Raveendra M" <raveendra_m@hotmail.com> schrieb im Newsbeitrag
news:038301c354cd$8e5aa580$a501280a@phx.gbl...> 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\\M yClass.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\\My Clas
> 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.
Jerry Guest
-
Unregistered #3
Problem with Building DLL after the AppDomain is unloaded.
Use this for load dll.This code not lock file.
FileStream fs = File.Open(@"C:\TestDll.dll",FileMode.Open);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
fs.Flush();
fs.Dispose();
fs = null;
Assembly a = Assembly.Load(data);Unregistered Guest



Reply With Quote

