FileSystemWatch and AppDomain.Unload

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

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

Guest

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

Guest

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
 

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

Top