473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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é
Nov 15 '05 #1
7 1754
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.com

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:eL****************@TK2MSFTNGP12.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é

Nov 15 '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.com> wrote in
message news:%2****************@TK2MSFTNGP09.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.com

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:eL****************@TK2MSFTNGP12.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é


Nov 15 '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.Exit. If it is not.... I don't
know... you have choices...
Ultimately you can call AppDomain.CurrentDomain.Unload.

HTH
B\rgds
100
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:eL****************@TK2MSFTNGP12.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é

Nov 15 '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.com

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:us**************@tk2msftngp13.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.com> wrote in message news:%2****************@TK2MSFTNGP09.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.com

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:eL****************@TK2MSFTNGP12.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é



Nov 15 '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**************@tk2msftngp13.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.Exit. If it is not.... I don't
know... you have choices...
Ultimately you can call AppDomain.CurrentDomain.Unload.

HTH
B\rgds
100
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:eL****************@TK2MSFTNGP12.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é


Nov 15 '05 #6
Got it. Need to call
_set_error_mode(_OUT_TO_STDERR);

Thanks for your great help!

José
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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**************@tk2msftngp13.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.Exit. If it is not.... I don't
know... you have choices...
Ultimately you can call AppDomain.CurrentDomain.Unload.

HTH
B\rgds
100
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:eL****************@TK2MSFTNGP12.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é



Nov 15 '05 #7
100
Great! :-)

B\rgds
100

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

Thanks for your great help!

José
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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**************@tk2msftngp13.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.Exit. If it is not.... I don't
know... you have choices...
Ultimately you can call AppDomain.CurrentDomain.Unload.

HTH
B\rgds
100
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:eL****************@TK2MSFTNGP12.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é
>
>



Nov 15 '05 #8

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

Similar topics

11
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...
7
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...
1
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....
10
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...
2
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...
6
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...
6
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...
2
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.