Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
1.33/5 (4 votes)
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....

Thanks
Posted

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.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Sep-11 14:09pm    
Good point, my 5. I added some explanation in my answer.
--SA
Member 12224368 7-Nov-17 4:33am    
Thank You John Simmons, I have created a "Class library" project and i did build its generated dll with project name. I guess i need to write the logic under the library class and rebuild project, to add reference select generated dll to my current project where i required. am I correct ?
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'.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Sep-11 14:10pm    
That's basically it, but in a simplest settings, my 5. Please see my additional explanations in my solution.
--SA
Wendelius 5-Sep-11 14:15pm    
Thanks SA.
Member 12224368 7-Nov-17 4:34am    
Thank you Wendelius. I will try to do what you said.
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.

—SA
 
Share this answer
 
Comments
Wendelius 5-Sep-11 14:14pm    
Very good explanation, +5
Sergey Alexandrovich Kryukov 5-Sep-11 14:15pm    
Thank you, Wika.
How could you be so fast? :-)
--SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900