Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6146339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:56:00+00:00 2026-05-23T18:56:00+00:00

I am using a badly written 3rd party (C/C++) Api. I used it from

  • 0

I am using a badly written 3rd party (C/C++) Api. I used it from managed code( C++/ CLI). Get sometimes “access violation errors”. And this crash whole application. I know i can not handle those errors[ what can i do if a pointer acess to illegal memory location etc].

But I do not want my application crash as a whole. At least if there is a real problem, my application gracefully should say “OK.I can not do my job.BYE. ” 🙂 then it least execute some alternative scenarious and finally close itself.

But there seems to be no way, to catch( may be wrong term, the rigth word may be to be informed about) access violation and similiar errors.Is there a way to be informed about those errors. So i can execute my alternative scenarious.

PS: Standard Exception handling does not solve this.

#include "stdafx.h"
#include <iostream>

using namespace System;

using namespace std;


static void ThrowingManagedException()
{

    throw gcnew ArgumentException("For no good reason");

}

static void ThrowingNativeException()
{

    throw std::exception("For no good reason");



}

static void SomeBadThingsHappen()
{

    short a[1]; 

    a[0]=1;

    a[2]= 2; // SomeOne make stupid mistake

}

int main(array<System::String ^> ^args)
{
    Console::WriteLine(L"Test Exceptions");

    try 
    {

        SomeBadThingsHappen();
         //ThrowingNativeException();         
         //ThrowingManagedException();
    }


    catch(Exception^ e)
    {
        Console::WriteLine("Something awful happened: "+ e);
    }


    Console::WriteLine("Press enter to exit");
    Console::Read();

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:56:01+00:00Added an answer on May 23, 2026 at 6:56 pm

    If you’re sure that the problems are bugs in the library, and not a result of you passing in bad arguments, then your most robust option is inter-process communication with a hosting process that loads the library. That way your OS process separation keeps the library from bringing down your application.

    You can try to catch access violations in-process, using SEH, but if the library writes to wild pointers and not simple null pointers, then the process won’t survive even with an exception handler.

    Your example will not cause an access violation, it’s a buffer overrun of a buffer on the stack, so the adjacent memory location contains some other valid data which gets stomped on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using a badly written windows service, which will hang when we are
I've got some (badly written) legacy code that I have to modify but I'm
Occasionally I will have some badly formed PHP code and I will get a
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I'm part of a testing team and have been tasked with behaving badly using
I am using a small java smtp library ( http://code.google.com/p/subethasmtp/ ), by this I
I need it so badly I have been trying it from 3 days but
I'm using the bulk loader to download my Review kind from one GAE server
I'm using (have to) a badly designed Oracle(10) DB, for which I don't have
I've written a script that changes the CSS elements on a badly designed page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.