473,545 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repost: Isolation In AppDomain - How to prevent the main AppDomain to crash when another AppDomain Crashes??????

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é
Jul 21 '05 #1
7 2366
Jose,

Unfortunately, in C, the abort function will terminate the process that
it is running in. If it does this, then I don't think that there is a
workaround for it. You will have to run this separately in another process
and marshal any calls/values back to you.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:eL******** ********@TK2MSF TNGP12.phx.gbl. ..
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é

Jul 21 '05 #2
Harrrrg,

Let's say I make a modification to this legacy library and install a "signal
handler" that will send, through a delegate, information that an exception
occured.
Is there a way to unload the AppDomain where the C code is loaded without
having my main domain to miserably terminate?

José

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Jose,

Unfortunately, in C, the abort function will terminate the process that it is running in. If it does this, then I don't think that there is a
workaround for it. You will have to run this separately in another process and marshal any calls/values back to you.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:eL******** ********@TK2MSF TNGP12.phx.gbl. ..
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é


Jul 21 '05 #3
100
Hi Jose,
*abort* terminates the whole process. So all application domains on it will
be terminated. What you can do is to install signal handler for SIGABRT
signal. Hopefully you can do it form managed code with P/Invloke.

So maybe you will install that handler form the same application domain that
you want to terminate.
If it is a GUI you can call Application.Exi t. If it is not.... I don't
know... you have choices...
Ultimately you can call AppDomain.Curre ntDomain.Unload .

HTH
B\rgds
100
"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:eL******** ********@TK2MSF TNGP12.phx.gbl. ..
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é

Jul 21 '05 #4
Jose,

This would work much better. If you have your C code changed so that it
issues an error code of some sort, instead of calling abort, that would be
optimal. Then, from the managed side, you can decide what to do when it
fails.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:us******** ******@tk2msftn gp13.phx.gbl...
Harrrrg,

Let's say I make a modification to this legacy library and install a "signal handler" that will send, through a delegate, information that an exception
occured.
Is there a way to unload the AppDomain where the C code is loaded without
having my main domain to miserably terminate?

José

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Jose,

Unfortunately, in C, the abort function will terminate the process that
it is running in. If it does this, then I don't think that there is a
workaround for it. You will have to run this separately in another

process
and marshal any calls/values back to you.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:eL******** ********@TK2MSF TNGP12.phx.gbl. ..
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é



Jul 21 '05 #5
I did this directly in the C Library (just as a quick test).

This sounds now much better. I'm able to unload the appDomain directly
within the faulty AppDomain.
I'm also able to reload it again from the main AppDomain.

HOWEVER!!!!
I always get a popup message when the dll containing the C code terminates:
Visual C++ Runtime Library
Runtime Error!
This application has requested the Runtime to terminate it in an unusual
way.

And the Service locks until I press OK...

Is there a way to prevent such a message to be thrown?


======= C code snippet =========
// JOJ
signal(SIGABRT, inthandler);
signal(SIGFPE, inthandler);
signal(SIGILL, inthandler);
signal(SIGSEGV, inthandler);
// JOJ

....
....
void
inthandler (int arg)
{
// JOJ: Write info to local memory log and call our delegate to inform
about the problem
......
(*ExitRamitPtr) (9999);
return;
}
"100" <10*@100.com> wrote in message
news:e8******** ******@tk2msftn gp13.phx.gbl...
Hi Jose,
*abort* terminates the whole process. So all application domains on it will be terminated. What you can do is to install signal handler for SIGABRT
signal. Hopefully you can do it form managed code with P/Invloke.

So maybe you will install that handler form the same application domain that you want to terminate.
If it is a GUI you can call Application.Exi t. If it is not.... I don't
know... you have choices...
Ultimately you can call AppDomain.Curre ntDomain.Unload .

HTH
B\rgds
100
"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:eL******** ********@TK2MSF TNGP12.phx.gbl. ..
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é


Jul 21 '05 #6
Got it. Need to call
_set_error_mode (_OUT_TO_STDERR );

Thanks for your great help!

José
"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
I did this directly in the C Library (just as a quick test).

This sounds now much better. I'm able to unload the appDomain directly
within the faulty AppDomain.
I'm also able to reload it again from the main AppDomain.

HOWEVER!!!!
I always get a popup message when the dll containing the C code terminates:
>>>> Visual C++ Runtime Library
Runtime Error!
This application has requested the Runtime to terminate it in an

unusual way. >>>>
And the Service locks until I press OK...

Is there a way to prevent such a message to be thrown?


======= C code snippet =========
// JOJ
signal(SIGABRT, inthandler);
signal(SIGFPE, inthandler);
signal(SIGILL, inthandler);
signal(SIGSEGV, inthandler);
// JOJ

...
...
void
inthandler (int arg)
{
// JOJ: Write info to local memory log and call our delegate to inform
about the problem
......
(*ExitRamitPtr) (9999);
return;
}
"100" <10*@100.com> wrote in message
news:e8******** ******@tk2msftn gp13.phx.gbl...
Hi Jose,
*abort* terminates the whole process. So all application domains on it will
be terminated. What you can do is to install signal handler for SIGABRT
signal. Hopefully you can do it form managed code with P/Invloke.

So maybe you will install that handler form the same application domain

that
you want to terminate.
If it is a GUI you can call Application.Exi t. If it is not.... I don't
know... you have choices...
Ultimately you can call AppDomain.Curre ntDomain.Unload .

HTH
B\rgds
100
"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:eL******** ********@TK2MSF TNGP12.phx.gbl. ..
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é



Jul 21 '05 #7
100
Great! :-)

B\rgds
100

"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:ua******** ********@tk2msf tngp13.phx.gbl. ..
Got it. Need to call
_set_error_mode (_OUT_TO_STDERR );

Thanks for your great help!

José
"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
I did this directly in the C Library (just as a quick test).

This sounds now much better. I'm able to unload the appDomain directly
within the faulty AppDomain.
I'm also able to reload it again from the main AppDomain.

HOWEVER!!!!
I always get a popup message when the dll containing the C code

terminates:
>>>>

Visual C++ Runtime Library
Runtime Error!
This application has requested the Runtime to terminate it in an

unusual
way.
>>>>


And the Service locks until I press OK...

Is there a way to prevent such a message to be thrown?


======= C code snippet =========
// JOJ
signal(SIGABRT, inthandler);
signal(SIGFPE, inthandler);
signal(SIGILL, inthandler);
signal(SIGSEGV, inthandler);
// JOJ

...
...
void
inthandler (int arg)
{
// JOJ: Write info to local memory log and call our delegate to inform
about the problem
......
(*ExitRamitPtr) (9999);
return;
}
"100" <10*@100.com> wrote in message
news:e8******** ******@tk2msftn gp13.phx.gbl...
Hi Jose,
*abort* terminates the whole process. So all application domains on it

will
be terminated. What you can do is to install signal handler for SIGABRT signal. Hopefully you can do it form managed code with P/Invloke.

So maybe you will install that handler form the same application
domain that
you want to terminate.
If it is a GUI you can call Application.Exi t. If it is not.... I don't
know... you have choices...
Ultimately you can call AppDomain.Curre ntDomain.Unload .

HTH
B\rgds
100
"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:eL******** ********@TK2MSF TNGP12.phx.gbl. ..
> 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é
>
>



Jul 21 '05 #8

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

Similar topics

11
12671
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to read the new date. So process B starts "select ..." but does not get the previously inserted row. The timespan between commit and select is very short....
1
4097
by: MatthewRoberts | last post by:
Howdy All, I am having difficulty with two-way communication across AppDomains in an attempt to dynamically script applications. Everything works as expected, except when using ByRef parameters. The below explanation is lengthy, but well worth the read. If you can help me, I'd gladly share this code which has greatly helped my...
10
9507
by: xixi | last post by:
i have db2 udb v8.1 on windows 64 bit 2003 server, after db2 server start , i found this in the db2diag.log, is this error? 2004-05-05-15.28.30.780000 Instance:DB2 Node:000 PID:1692(db2syscs.exe) TID:2860 Appid:AC10040A.GD5F.00FC56D8BEC5 base sys utilities sqledint Probe:30 Crash Recovery is needed. 2004-05-05-15.28.31.890000 ...
2
1523
by: José Joye | last post by:
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...
7
1758
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é
6
8178
by: Wal Turner | last post by:
Hi there. There are various snippets on forums regarding issues with AppDomain.Unload and how it just doesnt work. Fortunately, I got it working with the base case, after much fiddling. Consider this 5 line program: AppDomain domain = AppDomain.CreateDomain("MyDomain"); domain.CreateInstance("TempDLL", "TempDLL.Class1");...
6
2883
by: pradeep_TP | last post by:
Hi all, I am using IIS 5.0 and this question is regarding working of ASP.net worker process. I have only one web application right now on my web server. This means that only one AppDomain will be created inside a single worker process. NOw for example, due to some reason, my web application generated a stack overflow error and crashed my...
2
2109
by: ray | last post by:
I have a client that doesn't want Access to automatically repair into a backup file if it crashes (and it crashes only on very rare occasions). My (sketchy) understanding is that this is a Windows function that can't be stopped by using runtime switches, advanced options or other hi-falutin' database properties. Ami I correct that the...
1
2484
by: José Joye | last post by:
I'm currently trying to load an instance of a given class within a secondary appDomain and access it from within my main AppDomain. Everything is fine and working if the class in the second AppDomain catches any potential exception. However, if I throw an error within a method that is implemented in the object running in the 2nd AppDomain,...
0
7499
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...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
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...
0
6022
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...
1
5359
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5076
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...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.