Click here to Skip to main content
13,049,263 members (68,374 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi everybody
i m having serious problem these days
I m building a project but i have to write all code again and when i use that code
in different project.
Moreover my code is not secure too.
I have heard about making your own dll files in .net which
not only allows you to use it again and againn but also it provides security to your code too.

Can anyone help me out in this how to make dll files. in .net 2.0 or above.

Any kind of help will be highly appreciated....

Posted 5-Sep-11 3:01am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

In visual studio, create a "Class library" project. This will result in a DLL when you compile.

Creating a DLL doesn't protect your code (if you're talking about reverse engineering). In fact, NOTHING you can do will completely protect your .Net code.
SAKryukov 5-Sep-11 14:09pm
Good point, my 5. I added some explanation in my answer.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

To add to John Simmons answer, when you start building a DLL, it's perhaps easiest to set up a solution where you have one project for the dll and another project for the actual exe (or tester if you like).

In the executable project add a reference to the dll project. This way you can make modifications to the dll and see what's happening on the 'calling side'.
SAKryukov 5-Sep-11 14:10pm
That's basically it, but in a simplest settings, my 5. Please see my additional explanations in my solution.
Mika Wendelius 5-Sep-11 14:15pm
Thanks SA.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

If you only "have heard" about writing DLLs after some time of application development, you need seriously rethink your methods of learning and work. Don't proceed with development until you have clear understanding of basic platform capabilities and techniques. DLLs is one of such basic features.

First thing you need to understand, the major building block of .NET code is Assembly, not DLL, which is only a file extension. In .NET, there is not fundamental difference between .EXE and .DLL. Usually .EXE is used as a main executable module of an application, and a .DLL as a main executable module of a class library to be referenced by other assemblies (applications or libraries). But you can use .EXE file and reference it exactly the same way as a library. You can have an alternative host for running .NET application which would require DLLs with different structure than custom EXEs. The only difference of EXE is having an entry point (usually Main, but it can be changed).

Class libraries are used to provide code reuse, not for protection. They cannot add any protection at all. In general, boundaries between assemblies used in the same application domain are so thin that you hardly can feel them. In contrast, Application Domains and, hence, processes are strongly isolated.

Mika Wendelius 5-Sep-11 14:14pm
Very good explanation, +5
SAKryukov 5-Sep-11 14:15pm
Thank you, Wika.
How could you be so fast? :-)
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

One Just need to add Classlibrary from file >new project tab..
After you write your code click Build Solution in Build tab.

Then you click on project name in solution explorer and click show all files options

and now you can see two file bin and obj
Expand bin and then debug you will find your .dll file..

Now for using it close your current classlibrary project and open new project say windowsapplication add a button on form and go to code window..
Here click project option in menu bar and got to add reference options .Here you click browse tab and now you browse to the location where you have saved your file and click OK.
you are ready to use your self made .dll file..
Mehdi Gholam 7-Jan-12 8:04am
Use the comments if your require further assistance, do not post solutions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 10 Sep 2015
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100