从类文件创建程序集 [英] Creating a Assembly from Class files

查看:75
本文介绍了从类文件创建程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中很少有.CS文件,例如Item.cs,Stock.cs,Supplier.cs.
如何从这些.cs文件创建程序集.

[edit]将Assebly更正为Assembly [/edit]

I have few .CS files in my project like Item.cs,Stock.cs,Supplier.cs.
How can I create a Assembly from those .cs files.

[edit] corrected Assebly to Assembly[/edit]

推荐答案

如果不进行编译,就无法有效地对这些文件进行编程.如果在某个项目中编译它们,则结果始终是一个Assembly.总是,而不是排除.不管是* .DLL还是* .EXE.对于.NET,差异不明显.两者都可以用作一个库(对于许多开发人员来说,这是一个惊喜!),但是* .EXE也可以从命令行管理程序中运行.同样,扩展可以是任何东西. * .EXE文件不是由扩展名真正识别的,而是由入口点识别的.

其余的取决于您使用的是什么.如果使用Visual Studio,则将创建一个空项目,并使用添加现有项"将这些文件添加到其中.不用了您可以使用裸机编译器.有关更多详细信息,请参见编译器文档.

—SA
You could not effectively program these file without compiling them. If you compile them in some project, the result if it is always an Assembly. Always, not exclusions. It does not matter if it is *.DLL or *.EXE. For .NET, the difference is insignificant. Both can be used a a library (for many developers it will be a surprise!), but *.EXE can also be run from the Shell. Also, extension can be anything; *.EXE file is recognized not really by extension, but by the entry point.

The rest depends on what are you using. If you use Visual Studio, you create an empty project and adds those files to it, using "Add existing item". You don''t have to. You can use the bare compiler. See compiler documentation for more detail.

—SA


桑耶夫,

您可以创建程序集,而无需将这些文件添加到项目中.
只需做一件事,将所有类添加到命名空间即可.
并在命令提示符下进行编译,例如

csc/out:<文件名> /t:库< file1> < file2>

/t:库-DLL
/t:exe-EXE

问候
Ankit
Hi Sanjeev,

You can create a assembly without adding these files into a project.
Just do one thing, add all the classes into a Namespace.
and complie them from command prompt e.g.

csc /out:<filename> /t:library <file1> <file2>

/t:library - DLL
/t:exe - EXE

Regards
Ankit


您将项目输出类型转换为类库.

最好的问候,
Theingi Win
You convert your project output type to class library.

Best Regard,
Theingi Win


这篇关于从类文件创建程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆