Do I have to have Main to compile my C# file?

ajoo 2002-06-18 12:50:12
What if I just want to write some libs?

Thanks a lot!
...全文
37 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2002-06-18
  • 打赏
  • 举报
回复
you can use switches like
/reference:SomeOtherDll.dll;SomeOtherDll2.dll /lib:ThePathToSomeOtherDll1,ThePathToSomeOtherDll2

you can also add these options in csc.rsp located in C:\WINNT\Microsoft.NET\Framework\v1.0.3705\csc.rsp
which C# compiler reads automatically
ajoo 2002-06-18
  • 打赏
  • 举报
回复
when I deploy my class lib, am I deploying just a dll file? how my users compile their code which uses my class?
Java has class path so that it can find the class file, how can CLR find the dll containing my class?

for example, My user write:
class Test{
void f(){LibClass.fff();}
};
and the LibClass is in my blahblah.dll,
how can clr find out that the LibClass is actually in the "blahblah.dll"?

saucer 2002-06-18
  • 打赏
  • 举报
回复
theoretically, they could be run on all platforms as long as there are .NET runtime on these platforms and you did not use Windows specifics, but as you know, that may never the case

exe has a Main entry point and can be executed alone, while dll cannot
ajoo 2002-06-18
  • 打赏
  • 举报
回复
why the result is .dll or .exe?
does that imply the result file can only be run on a specific OS?
saucer 2002-06-18
  • 打赏
  • 举报
回复
no, you do not need to, but you need to specify the output target to be a library type, for example:

csc /target:library /out:TestMain.dll TestMain.cs

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧