DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Trending

  • The Evolution of Scalable and Resilient Container Infrastructure
  • Yet Another GenAI Nightmare: Seven Shadow AI Pitfalls to Avoid
  • The End of “Good Enough Agile”
  • Securing Kubernetes in Production With Wiz

C# – Creating a DLL to Hide Your Code

By 
Sourabh Sharma user avatar
Sourabh Sharma
·
Mar. 06, 13 · Interview
Likes (0)
Comment
Save
Tweet
Share
34.3K Views

Join the DZone community and get the full member experience.

Join For Free

The DLL also called Dynamic Link Library is a file that can be used dynamically by other programs. We create the DLL mainly to hide our confidential code so that we can use the code everywhere but can not see the code. When we talk about the layers or 3 and above tier application we need to understand one thing that why we create layers in our project. We only show some part of code to everyone and hide the main coding part. The benefit is we can use this code but can not see this.

Advantages of creating DLL: 
There are many advantages of using the DLL in your Application but We are talking about the main advantages: 
1. DLL is used to hide the code so anyone can use the functionality but no one can steal the code.
2. Once we create a DLL then it can be used in many applications. We just have to import that dll into our project.
3. Adding a dll into your project is very simple. It reduces time to write the code again and again. In C#.Net you need to just import dll with add reference in your project. 
Now we will see that how we can create a dll and then how the dll can be used in the application. Creating DLL: 
Step 1: Open Visual Studio and Create New Project by Clicking New->Project 
1  

Step 2: Select 'Class Library' from the list and click Ok. 
2

Step 3: Now you will see the following screen
3

Step 4: Change the name Class1. As I have changed the Name with MyCode and Write the code what you want to use in your DLL.
4 

Step 5: Now Click Build Menu -> Build Solution to complete the process. Now you can see the dll file with .dll extention inside you project folder. Now the dll is ready to use inside other application.

Step 6: Create a New Project. Then Right click on Project Name -> Add Reference -> Select the dll File to add as reference into your project.

5

Step 7: Now you need to include the namespace for that dll by using the following code.
using ClassLibrary2;
Step 8: Now you can access the method of that dll and the code will be hidden to you. You can access the method of dll file by using the following code.

private void button1_Click(object sender, EventArgs e)
        {
            int x, y;
            x = Convert.ToInt32(txtNo1.Text);
            y = Convert.ToInt32(txtNo2.Text);
            MyCode ob = new MyCode();
            int c = ob.sum(x, y);
            txtResult.Text = c.ToString();
        }

As in Example you can see that how we have created a dll and then how we used that dll into our project.
You can also see the articles How to use Crystal Report in C#.Net.

Opinions expressed by DZone contributors are their own.

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: