repost: AppDomain and unexpected termination

J

José Joye

I have a library written in C (I do not have the source) and having some
callbacks exported. It is currently not that stable and write to stdout and
stderr
:-((
The idea I have is to wrap it with a C# class and instanciate an instance of
this class within a new AppDomain.

Here are my question:

Am I correct to assume that I will be able to handle cases where the library
fails. If yes, how will the main AppDomain know about a termination of the
other AppDomain?


Is there a way to redirect stdout and stderr for a newly created appDomain?


Thanks,
José
 
N

Nicholas Paldino [.NET/C# MVP]

Jose,

You can use the DomainUnload event to be notified when an application
domain is about to be unloaded. If your application domain terminates
abnormally, then this should fire.

As for redirecting stdout and stderr, you don't really have to do that,
as stdout and stderr's affinnity is for the process (which the app domain
will be in). It should just work.

Hope this helps.
 
J

José Joye

Thanks for your answer.

regarding my 2nd question, I had the problem that my main program was a
service. In that particular case, stdout is particulary annoying...
Therefore, I had to find a workaround. I have redirected stdout and stderr
to files using "SetStdHandle".

José


Nicholas Paldino said:
Jose,

You can use the DomainUnload event to be notified when an application
domain is about to be unloaded. If your application domain terminates
abnormally, then this should fire.

As for redirecting stdout and stderr, you don't really have to do that,
as stdout and stderr's affinnity is for the process (which the app domain
will be in). It should just work.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


José Joye said:
I have a library written in C (I do not have the source) and having some
callbacks exported. It is currently not that stable and write to stdout and
stderr
:-((
The idea I have is to wrap it with a C# class and instanciate an
instance
of
this class within a new AppDomain.

Here are my question:

Am I correct to assume that I will be able to handle cases where the library
fails. If yes, how will the main AppDomain know about a termination of the
other AppDomain?


Is there a way to redirect stdout and stderr for a newly created appDomain?


Thanks,
José
 

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