FileSystemWatch and AppDomain.Unload

  • Thread starter Thread starter Tao
  • Start date Start date
T

Tao

hi.. group,

A wired question about FileSystemWatcher and Unload an AppDomain.

I have a class A which creates class B. When B is created, B loads an
AppDomain and execute some functions on the load AppDomain.

B monitors disk to see if some files chang. If some file changes, B will try
to unload the AppDomain it loaded before.

Problem is the AppDomain.Unload never returns if it is called in
FileSystemWatcher event handler, it does not give exception either. The
AppDomain does not get unloaded.

I tried to unload after the function calls, unload works fine. Only in the
FileSystemWatcher, the AppDomain stucks and no exception, debug cursor
disappears.

It is really wired.

Thanks
 
Hi,

Tao said:
hi.. group,

A wired question about FileSystemWatcher and Unload an AppDomain.

I have a class A which creates class B. When B is created, B loads an
AppDomain and execute some functions on the load AppDomain.

B monitors disk to see if some files chang. If some file changes, B will
try to unload the AppDomain it loaded before.

Problem is the AppDomain.Unload never returns if it is called in
FileSystemWatcher event handler, it does not give exception either. The
AppDomain does not get unloaded.


What kind of app is this?
IF a win app use Application.ThreadException

Additionally use AppDomain.UnhandledException

Most probably you are getting an exception somewhere.
 
Thanks, Ignacio,

That is something really wired. It just stop there, I put

try.. catch (exception ex)

No exception, does not return. But it is good that it does not freeze the
whole application though.
 
BTW: the application is a disaster for C# developer.

the main app is C++ (not managed), it starts up a .NET runtime component and
invoke a managed class. The managed class is where I starts.

thanks
 
Back
Top