0

My question is simple

1- is the dll we used in c# compiled to binary ?

if the answer is yes ?

2- so how can i reuse it in another app what i meant when i create another c# project i can go and using the same name of the dll and i can use all the class Which is inside the dll (I suppose I can't use it again Because it turned into a binary)

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
  • You might look at .net assembly concept – Pavel Anikhouski Apr 30 '20 at 20:59
  • 1) In a sense yes. The source code is transformed in [CIL](https://en.wikipedia.org/wiki/Common_Intermediate_Language) and is in a binary form. 2) Yes you just need to add into the new project a [reference](https://stackoverflow.com/questions/12992286/how-to-add-a-dll-reference-to-a-project-in-visual-studio) to your dll. 3) Yes because the source code is not transformed in machine code but in CIL (see 1 above) – Steve Apr 30 '20 at 21:00
  • 1
    Please post a single question. Even than chances are that single question is far too broad. – MakePeaceGreatAgain Apr 30 '20 at 21:02
  • I removed "how decompilers like dnSpy/ILSpy/DotNetPeak/... able to convert .Net assembly into original code" question... As @HimBromBeere said ask one well researched question per post. – Alexei Levenkov Apr 30 '20 at 21:11

2 Answers2

2

C# is one of the .NET languages. So I will try to speak in .NET Terms.

1- is the dll we used in c# compiled to binary ?

No, everything .NET is compiled to MSIL. Not binary, not machine code. It is the job of the runtime to do the final translation to machine code.

You can roughly compare MSIL code to Java Bytecode.

2- so how can i reuse it in another app what i meant when i create another c# project i can go and using the same name of the dll and i can use all the class Which is inside the dll

The exact same way, you already use the dll's wirrten by the .NET Team:

  1. Add Reference to project.
  2. Use fully qualified names and/or using directives.

Note that .exe can also be used as reference. Their internal structure is pretty similar to .NET .dll, except for some native bootstrap code and a start point.

Christopher
  • 9,634
  • 2
  • 17
  • 31
0

I want only to add, that you can reuse assembly even without direct reference in your project since assembly can be loaded in runtime, but the usages of types from it will be more tricky, more about that, you can find, for example, in this answer