Problem with removing file.dll from application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Helo

The Application makes kod.cd file.
After that I use:
CodeDomProvider provider = new CSharpCodeProvider();
and so on - as NSDN shows - Ctr+C and Ctr+V -> working fine.
After good compilation I call SYM object
public class SYM : KOD
{
call some function from KOD;
}
Till now working perfect.
But I can not do this again.
When I try do this I have error that file kod.dll
is used and I can not compile kod.cs to kod.dll again.
Some how I have to free that file from current process.
In order to do this I do:
System.Diagnostics.Process.GetCurrentProcess().Modules[index of
kod.dll].Dispose();

GC.SuppressFinalize(System.Diagnostics.Process.GetCurrentProcess().Modules[i
ndex of kod.dll]);

But it's not working.

I need some help with this.
Robert Janda
 
Hello Robert,

You cannot unload a single .dll from an application domain, the whole
application domain must be shut down (at least this is true for .NET 1.1).
Therefore, create a secondary app. domain, compile and load the "kod"
assembly into that domain, as well as load all code using the KOD class to
that domain. When you need to recompile the base KOD class, shut down the
whole domain, recompile kod.dll, re-create the app. domain and re-load all
the necessary assemblies into the new app. domain.
 
Hi Dmytro

I resolved the problem.
I compile the different dll file and I'm loading this dll usig assambly.

Thanks.

Dmytro Lapshyn said:
Hello Robert,

You cannot unload a single .dll from an application domain, the whole
application domain must be shut down (at least this is true for .NET 1.1).
Therefore, create a secondary app. domain, compile and load the "kod"
assembly into that domain, as well as load all code using the KOD class to
that domain. When you need to recompile the base KOD class, shut down the
whole domain, recompile kod.dll, re-create the app. domain and re-load all
the necessary assemblies into the new app. domain.

Robert said:
Helo

The Application makes kod.cd file.
After that I use:
CodeDomProvider provider = new CSharpCodeProvider();
and so on - as NSDN shows - Ctr+C and Ctr+V -> working fine.
After good compilation I call SYM object
public class SYM : KOD
{
call some function from KOD;
}
Till now working perfect.
But I can not do this again.
When I try do this I have error that file kod.dll
is used and I can not compile kod.cs to kod.dll again.
Some how I have to free that file from current process.
In order to do this I do:
System.Diagnostics.Process.GetCurrentProcess().Modules[index of
kod.dll].Dispose();

GC.SuppressFinalize(System.Diagnostics.Process.GetCurrentProcess().Modules[i
ndex of kod.dll]);

But it's not working.

I need some help with this.
Robert Janda
 
Back
Top