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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:22:14+00:00 2026-06-06T09:22:14+00:00

I have c#.net code which calls a method from another external/referenced .net assembly. This

  • 0

I have c#.net code which calls a method from another external/referenced .net assembly. This method I am calling throws an exception if a certain property from the object I am passing it is null. Here it is in a nutshell:

public void Add(string key, object obj)
{
..
//if the Foo property from obj is null then
throw new Exception("Foo property is null or empty")
..
}

In my client code which calls the DLL’s Add method, I would like to be able to detect that this particular exception was raised, maybe distinguished by its “Foo property is null or empty” message. Currently, I get a NullReferenceException when it hits this method, so I catch this exception.

Question1:
Can I get the error message associated with the exception being thrown by the code I am calling (in the referenced assembly)??

Question2:
Is this considered bad practice or maybe just atypical?

Obviously, I can disassemble the third-party DLL to discover that my obj I’m passing in must have this “Foo” property set. So, my question here is somewhat for the sake of exercise (and because I’m a n00b).

  • 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-06-06T09:22:15+00:00Added an answer on June 6, 2026 at 9:22 am

    Catching System.Exception and showing the exceptions Message property is all I needed. At first, I kept getting a NullReferenceException with “Object reference not set to instant of an object” message at the Add method, but I was expecting to get an Exception with the message “Foo property is null or empty” error. Some condition changed in my code and I now get what I expect.

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

Sidebar

Related Questions

I have a script code in vb.net environment which is calling file from path
I have an ASP.NET MVC server app and client code which uses jquery. I'd
I have the following code which is created with a datalist control: http://jsfiddle.net/vmE2E/1/ But
I have a master page in my asp.net MVC project, which has code like
I have somebody elses code (C# ASP.Net) which contains the following query: string query
I have ADO.Net code as below, that calls a stored procedure. Within the stored
I have a .NET 3.5 winforms app that calls a method in a VB6
I have an ASP.Net-Button which, when clicked, executes client side and server side code.
I have an ASP.NET gridview component which is being filled up with data from
I just copied some code from an asp.net mvc 2 app which works. Now

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.