473,657 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

repost: AppDomain and unexpected termination

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é
Nov 15 '05 #1
2 1529
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]
- mv*@spam.guard. caspershouse.co m
"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:uv******** ******@tk2msftn gp13.phx.gbl...
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é

Nov 15 '05 #2
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 "SetStdHand le".

José
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:Ol******** ******@TK2MSFTN GP11.phx.gbl...
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]
- mv*@spam.guard. caspershouse.co m
"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:uv******** ******@tk2msftn gp13.phx.gbl...
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é


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
6693
by: A Ratcliffe | last post by:
As you might have gathered from the Subject, I've been experimenting with using VBScript classes in my ASP pages to tidy the script up. Generally things are going well. Since I come from a C++ background, I have long made use of singleton objects, in various forms, and I can see an obvious use for one here but not sure if I can. I'll explain the situation:- I have a cDataLink class, configured via a couple of Const defines for the...
7
2373
by: José Joye | last post by:
I have a windows service where I create another appdomains. In the newly created AppDomain, I make use of a C library. If I issue an Abort(1) within this library, it simply hard stop my main AppDomain!!!!!!!!!!!!How could I prevent my main AppDomain to stop when the other stopped?Thanks a lot,José
2
10433
by: Attila Feher | last post by:
Hi all, I have not done much work around exceptions; and even when I do I avoid exception specifications. But now I have to teach people about these language facilities, so I am trying them out with gcc 3.4.2-mingw. I have tried the TCPL Spec.Ed. example of just adding std::bad_exception to the exception specification of a function promising to throw an int, but throwing a string-literal (effectively a pointer). I call that from main...
0
924
by: José Joye | last post by:
I have a library written in C (I do not have the source) and having some callback. 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
5
2539
by: jake | last post by:
I've seen many articles that claim the files in the App_Code directory are treated in the same way as aspx-files in ASP 1.1. Well, this does not seem to be the case, at least in Web Developer 2005 Express Beta2. If I change anything in any of the class files residing in App_Code, the AppDomain is unloaded and all application data, including all sessions, is lost. Is there anything I can do to prevent this? This undesired side-effect...
32
4400
by: Rene Pijlman | last post by:
One of the things I dislike about Java is the need to declare exceptions as part of an interface or class definition. But perhaps Java got this right... I've writen an application that uses urllib2, urlparse, robotparser and some other modules in the battery pack. One day my app failed with an urllib2.HTTPError. So I catch that. But then I get a urllib2.URLError, so I catch that too. The next day, it encounters a urllib2.HTTPError, then...
669
25859
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Languageâ€, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
4
5337
by: illegal.prime | last post by:
Hi all, I'm getting unexpected results when trying to preload assemblies into an AppDomain I'm creating. Upon creation of the AppDomain - I attach an AssemblyResolve to both my current AppDomain and the new AppDomain I create. I copy all the assemblies/dlls into a new directory and then try loading them all into the new AppDomain using the following: private void LoadAssembliesFromDirectory(AppDomain appDomain, string directory)
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.