Creating a .dll file in C#.Net

2019-02-01 07:34发布

I had created a project which is C# console application project for which I need to call this project dll in another windows application project. I had built the project in visual studio 2010 and checked for .dll file in bin\debug folder, but it is not created.

But a manifest file and .exe file havebeen created. Please help me out how to create the .dll in this case.

标签: c# .net file dll
4条回答
SAY GOODBYE
2楼-- · 2019-02-01 08:02

Console Application is an application (.exe), not a Library (.dll). To make a library, create a new project, select "Class Library" in type of project, then copy the logic of your first code into this new project.

Or you can edit the Project Properties and select Class Library instead of Console Application in Output type.

As some code can be "console" dependant, I think first solution is better if you check your logic when you copy it.

查看更多
▲ chillily
3楼-- · 2019-02-01 08:05

To create a DLL File, click on New project, then select Class Library.

Enter your code into the class file that was automatically created for you and then click Build Solution from the Debug menu.

Now, look in your directory: ../debug/release/YOURDLL.dll

There it is! :)

P.S. DLL files cannot be run just like normal applciation (exe) files. You'll need to create a separate project (probably a win forms app) and then add your dll file to that project as a "Reference", you can do this by going to the Solution explorer, right clicking your project Name and selecting Add Reference then browsing to whereever you saved your dll file.

For more detail please click HERE

查看更多
劫难
4楼-- · 2019-02-01 08:16

You need to change project settings. Right click your project, go to properites. In Application tab change output type to class library instead of Windows application.

查看更多
乱世女痞
5楼-- · 2019-02-01 08:27

You need to make a class library and not a Console Application. The console application is translated into an .exe whereas the class library will then be compiled into a dll which you can reference in your windows project.

  • Right click on your Console Application -> Properties -> Change the Output type to Class Library

enter image description here

查看更多
登录 后发表回答