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 6618605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:51:22+00:00 2026-05-25T20:51:22+00:00

I’m working on various C++ COM DirectShow filters called from C# clients via COM

  • 0

I’m working on various C++ COM DirectShow filters called from C# clients via COM interop. There’s little use of C++ exceptions in the code. The main exception is operator new which can throw bad_alloc exceptions.

Is there a clean way of handling bad_alloc exceptions in a way which can be caught by the C# client?

Could a new handler throw some an SEH exception that could be caught by COM interop clients?

Or would it be better to link with the backwardly-compatible non-throwing version of new in Visual Studio libraries and check every allocation?

One tedious alternative is to write a try/catch for hundreds of COM entry points which doesn’t seem worthwhile since bad_alloc exceptions are rarely recoverable.

The DirectShow base classes generally check for null returns from operator new as they seem to have been written for earlier versions of Visual C++ that didn’t throw bad_alloc exceptions.

  • 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-25T20:51:23+00:00Added an answer on May 25, 2026 at 8:51 pm

    The COM API contract requires that you not allow ANY C++ exceptions to flow across the COM API boundry.

    That means you need to catch all C++ exceptions and turn them into HRESULTs before they leave your COM API.

    You might be able to get away with this in some rare circumstances (if, for instance you can guarantee that the COM client and COM server were built with the same version ofthe compiler), but there are a myriad of circumstances that can mess this up (for instance the COM server lives behind a proxy/stub (which can happen if you have multiple apartments or if the server is out-of-proc), or if the COM server is being called from another language like one of the CLR languages).

    In general, something like:

     catch (...)
     { 
         return E_FAIL;
     }
    

    at the end of each of your COM APIs will go a long way to improve the robustness of your code.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.