Creating a .dll file in C#.Net

前端 未结 5 2116
半阙折子戏
半阙折子戏 2020-12-24 06:04

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

相关标签:
5条回答
  • 2020-12-24 06:25

    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.

    0 讨论(0)
  • 2020-12-24 06:30

    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.

    0 讨论(0)
  • 2020-12-24 06:31

    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

    0 讨论(0)
  • 2020-12-24 06:32

    Creating DLL File

    1. Open Visual Studio then select File -> New -> Project

    2. Select Visual C# -> Class library

    3. Compile Project Or Build the solution, to create Dll File

    4. Go to the class library folder (Debug Folder)

    0 讨论(0)
  • 2020-12-24 06:36

    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

    0 讨论(0)
提交回复
热议问题