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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:08:14+00:00 2026-05-23T09:08:14+00:00

I am using a dll that I got from the internet for utilizing a

  • 0

I am using a dll that I got from the internet for utilizing a webcam in C#. If it can’t find a webcam connected I would like to display something like “Unable to find a camera to use. Please verify that no other applications are using your camera at this time and try again”. The problem I am having is the creator of the dll included a try-catch in their dll programming…so my try-catch never see’s the exception because a “object referenced not set to an instance of an object” error comes up instead (formatted by a try/catch into a MessageBox). Is there a way I can override the built-in error handling before it displays the message and display my own?

  • 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-23T09:08:15+00:00Added an answer on May 23, 2026 at 9:08 am

    If you’re getting “object referenced not set to an instance of an object” (NullReferenceException), then it is likely they didn’t actually catch the exception.

    If you want to catch that exact case (and let others errors you don’t know about and can’t handle fall through – the proper way to do exception handling), you can try getting down and dirty with the stack information included with the exception:

    class Program
    {
        public static void DoSomething()
        {
            string blah = null;
            Console.WriteLine(blah.Length);
        }
    
        static void Main(string[] args)
        {
            try
            {
                DoSomething();
            }
            catch (NullReferenceException e)
            {
                string methodName = e.TargetSite.Name;
                Console.WriteLine(methodName);
    
                System.Diagnostics.StackTrace trace =
                    new System.Diagnostics.StackTrace(e, true);
    
                int lineNumber = trace.GetFrame(0).GetFileLineNumber();
                Console.WriteLine(lineNumber);
    
                if(methodName == "DoSomething" && lineNumber == 13)
                {
                    ShowErrorToUser(); // Todo: Implement this
                }
                else
                {
                    throw; // Just re-throw the error if you don't know where it came from
                }
            }
        }
    }
    

    Edit

    Found out in the comments that it really is being caught, and displayed in a message box.

    I will leave this answer since it is applicable to a similar situation, but not applicable to this situation. See OscarMK’s answer instead.

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

Sidebar

Related Questions

I've got a running process which is using 'Test.dll'. I would like to know
How can I develop applications in C# that can be further extended using DLL
I am writing a Win32 DLL library that can be redistributed. I am using
I'm calling a non-.NET dll from my project using P/Invoke, meaning that the .dll
I have some neural net code written in c# that would benefit from using
I've got an easy sample from the internet that works fine in the .NET
I am using C to write a DLL that provides basic database connection functionality
I have a COM inproc DLL that we are using in our product. Now
I have a VB6 dll that is trying to create a COM object using
I'm using a native DLL (FastImage.dll) in a C# ASP.NET Web Service that sometimes

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.