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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:53:35+00:00 2026-05-30T10:53:35+00:00

I have a dll written by someone else and that has many flaws. Let’s

  • 0

I have a dll written by someone else and that has many flaws. Let’s assume there is only one class defined in this DLL. I need to import this DLL and create an instance of this class.
The DLL code might be the following :

   [Serializable()]
    public class makeExceptionClass
    {
        public bool isStringNormalized(string aString)
        {
            // A null check should be performed
            return aString.IsNormalized();
        }
    }

I wrote a small program to check whether or not my program can still run even if the dll crashes. The program is just a proof of concept. It takes two arguments, the first is used to load directly the DLL from an assembly and the second is used to provoke a crash.
The code of the program is the following :

class Program
{
    [PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
    static void Main(string[] args)
    {
        string typeOfLoading = args[0];
        string crash = args[1];

        // Load the DLL
        if (typeOfLoading.Equals("direct") == true)
        {
            Console.WriteLine("Loading directly a DLL");
            Assembly anAssembly = Assembly.Load("unloadableDLL");    // Directly load the DLL
            unloadableDLL.makeExceptionClass anObject = (unloadableDLL.makeExceptionClass)anAssembly.CreateInstance("unloadableDLL.makeExceptionClass");

            if (crash.Equals("crash") == true)
            {
                bool test = anObject.isStringNormalized(null);
            }
            else
            {
                bool test = anObject.isStringNormalized("test");
            }
        }
        else if (typeOfLoading.Equals("indirect") == true)
        {
            Console.WriteLine("Loading indirectly a DLL");
            AppDomain anAppDomain = AppDomain.CreateDomain("RemoteLoaderDomain");   // Assume it does not fail;
            Type t = typeof(unloadableDLL.makeExceptionClass);
            unloadableDLL.makeExceptionClass anObject = (unloadableDLL.makeExceptionClass)anAppDomain.CreateInstanceAndUnwrap("unloadableDLL", t.FullName);

            if (crash.Equals("crash") == true)
            {
                bool test = anObject.isStringNormalized(null);
            }
            else
            {
                bool test = anObject.isStringNormalized("test");
            }
            Console.WriteLine("Unloading the domain");
            AppDomain.Unload(anAppDomain);                
        }
        else
        {
            // don't care
        }

        // terminate
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
    }
}

The problem is that my program crashes regardless if the dll is loaded directly or into an AppDomain.
I am completely new to C# (I started this morning) but I have a C++ background.

  • 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-30T10:53:37+00:00Added an answer on May 30, 2026 at 10:53 am

    Add try / catch around your call:

      try
      {
        if (crash.Equals("crash") == true)
        {
          bool test = anObject.isStringNormalized(null);
        }
        else
        {
          bool test = anObject.isStringNormalized("test");
        }
      } catch (Exception ex) {
        Console.WriteLine("exception in dll call: "+ex);
      } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dll that was written in c++, I need to use this
I have a DLL that is written in C++ and I want to suppress
I have a test suite DLL written in C# that uses Selenium.This is then
I have a very simple DLL written in unmanaged C++ that I access from
I have an application written in PHP that uses a COM dll written in
I have written a DLL that uses MS Word to spell check the content
We have a system that makes a use of 3rd party COM DLL written
First_Layer I have a win32 dll written in VC++6 service pack 6. Let's call
I have an *.exe project that was written in one solution under vs2005 and
I have a DLL that was written in C++ and called from a C#

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.