C# 将 .cs 转换为 .dll

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/330447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 23:27:12  来源:igfitidea点击:

Convert .cs to .dll

c#dll

提问by Arun

How can I compile a .cs file into a DLL?

如何将 .cs 文件编译为 DLL?

My project name is WA. In my binfolder after the compilation, I found:

我的项目名称是 WA。bin编译后在我的文件夹中,发现:

  • WA.exe
  • WA.vshost.exe
  • WA.pdb
  • WA.exe
  • WA.vshost.exe
  • WA.pdb

回答by mannu

You use a compiler. Csc.exe comes with the .NET Framework.

您使用编译器。Csc.exe 随 .NET Framework 一起提供。

Check this link: http://msdn.microsoft.com/en-us/library/78f4aasd.aspx

检查此链接:http: //msdn.microsoft.com/en-us/library/78f4aasd.aspx

You can also use an IDE like Visual Studio if you want the development process to be easier.

如果您希望开发过程更轻松,您还可以使用 Visual Studio 之类的 IDE。

回答by leppie

You have to compile it:

你必须编译它:

csc /t:library source.cs  -> source.dll

回答by Winston Smith

Are you using Visual Studio?

你在使用 Visual Studio 吗?

If you create a Class Library project in VS, add your .cs file and then compile the project, the output will be a .dll file.

如果你在 VS 中创建一个类库项目,添加你的 .cs 文件然后编译项目,输出将是一个 .dll 文件。

回答by terjetyl

Its automatically created for you when you run a build in visual studio. Check the bin folder in your project folder.

当您在 Visual Studio 中运行构建时,它会自动为您创建。检查项目文件夹中的 bin 文件夹。

回答by Iman

For your information there are two kinds of DLL file which named "Managed" and "Un-Managed". Managed type is which you can use and add to your references in Visual Studio IDE. However, if you want to convert each classes separately to Dll, you can use new windows application-> class library. After debugging and running that you can find DLL file in your source destination. Try it. P.S: Usually you forced to use more than one class in one DLL file.

供您参考,有两种 DLL 文件,分别名为“Managed”和“Un-Managed”。托管类型是您可以在 Visual Studio IDE 中使用和添加到您的引用的类型。但是,如果要将每个类分别转换为 Dll,则可以使用新的 windows 应用程序-> 类库。调试并运行后,您可以在源目标中找到 DLL 文件。尝试一下。PS:通常你被迫在一个 DLL 文件中使用多个类。