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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:27:23+00:00 2026-05-27T22:27:23+00:00

I want to have a referenced dll in my Windows Forms Application project. It

  • 0

I want to have a referenced dll in my Windows Forms Application project. It is imperative to me that the dll is encrypted at first, and later decrypted on runtime when it needs to be used.

Please consider the following example where a sub routine is originally encrypted, but then decrypted and instantiated. Note, this is a conceptual idea only, I have no clue as to how this needs to be done in terms of code.

Class clsSO
{
void myVoid()
{
Console.WriteLine("We are here now ...");
}
} // End class

The above code would be wrapped in a .dll and added as a referenced dll to my project. The dll would then be referenced and the sub routine called:

clsSo myRef = new clsSo();

myRef.myVoid();

Console output reads:

We are here now…

What I need to be done:
The contents of the wrapper dll will be encrypted and thus unreadable / unable to reference the class directly. So, the dll will somehow need to be decrypted, and dynamically updated with the decrypted data so that I can then reference it.

Does something like this already exist? Can it even be done?

I appreciate the time everyone!

Thanks,

Evan

  • 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-27T22:27:24+00:00Added an answer on May 27, 2026 at 10:27 pm

    You will need to Call Assembly.Load(Byte[]) on the decrypted bytes of your file. once you have that you will need to either use reflection or cast the class to a interface so you can access the methods.

    Here is a example

    class Example
    {
        static void Main(string[] args)
        {
            byte[] decryptedLibArray;
            using (var fs = new FileStream("clsSo.cDll", FileMode.Open, FileAccess.Read))
            using (var aesProvider = new AesCryptoServiceProvider())
            using (var aesTransform = aesProvider.CreateDecryptor(YourKey, YourIV))
            using (var cryptoStream = new CryptoStream(fs, aesTransform, CryptoStreamMode.Read))
            {
                decryptedLibArray = ReadFully(cryptoStream);
            }
    
            var lib = Assembly.Load(decryptedLibArray);
    
            IclsSO classInstance = (IclsSO)lib.CreateInstance("clsSO"); //If you use a namespace this will be namespace.clsSO
    
            classInstance.myVoid();
    
        }
    
        /// <summary>
        /// Reads data from a stream until the end is reached. The
        /// data is returned as a byte array. An IOException is
        /// thrown if any of the underlying IO calls fail.
        /// </summary>
        /// <param name="stream">The stream to read data from</param>
        public static byte[] ReadFully (Stream stream)
        {
            byte[] buffer = new byte[32768];
            using (MemoryStream ms = new MemoryStream())
            {
                while (true)
                {
                    int read = stream.Read (buffer, 0, buffer.Length);
                    if (read <= 0)
                        return ms.ToArray();
                    ms.Write (buffer, 0, read);
                }
            }
        }
    }
    
    interface IclsSO
    {
        void myVoid();
    }
    

    ReadFully is from this posting. Read it to see why I did not just do cryptoStream.Read(data, 0, decryptedLibArray.Length); There are some errors with the final example but the memory stream example he gives is perfect.

    However someone could just dump the ram of your program and get the decrypted binary, or possibly decompile your main program and get the decryption keys and just decrypt it themselves. So depending on how paranoid you are, you may still want to invest in a obfuscateor.

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

Sidebar

Related Questions

I have an application written in .NET 4.0 that i compile into a DLL
I have a shared reporting dll that is used in both windows and web.
I have a c# project that calls some functions from a c dll, the
I want to have a select-only ComboBox that provides a list of items for
I want to have a text box that the user can type in that
I'm looking at code that is new-to-me. I have c++ code in a project
We have a .NET application for Windows which is installed locally by Microsoft Installer.
I'm writing an application in C that can be extended at runtime by means
In my DirectShow application I have a third party DLL (a 32bit DirectShow filter)
What are the steps to deploying a project created in VS2008 (windows forms and

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.