Pack c # project in dll or other library

I have a C # project with many classes. Is it possible to pack this project (Console application) into a library (possibly a dll or something else) and call all the functions of a certain class from other programming languages?

EDIT: Here is the code:

 using System; using System.Text; 

namespace Test {class Program {public int aplusb (int a, int b) {return a + b; }

  public void hello() { Console.WriteLine("Helo world"); } } 

} Code> And the hierarchy in the project folder: - Properties - Recommendations - bin - Debugging --- Test.dll --- Test.exe --- Test.pdb --- Test.vshost.exe --- Test.vshost. exe.manifest - obj - x86 --- Debug ---- TempPE ----- DesignTimeResolveAssemblyReferencesInput.cache ----- Test.csproj.FileListAbsolute.txt ----- Test.dll ----- Test .pdb ----- ResolveAssemblyReference.cache - Program.cs

I checked both Test.dll from bin and obj. They are empty

+1
source share
4 answers

when you create the project, you get the dll in the corresponding bin folder.

You can use this DLL in another project by adding a link to this DLL. After that you can use its methods.

+1
source

Visual Studio Project Properties → Application → Output Type: Class Library

0
source

Yes, you can create a class library project. Just keep in mind that you are creating a dll with managed code, if you want to use it, for example, C ++, you need to do some additional stuff.

0
source

Class libraries created using .NET (which ultimately are DLLs) can only be used from other .NET applications or libraries, or — if you want to enable it — from COM.

As far as I know, it is impossible to create a DLL with C #, whose methods you can call from an unmanaged application (C, C ++, etc.). There are no so-called "exported methods", so the DLL viewer shows that it is empty. Try again with .NET Reflector or a similar decompiler and you will see that the methods are displayed.

0
source

Source: https://habr.com/ru/post/892881/


All Articles