C# make a DLL out of a Windows Forms Project

2019-04-26 20:29发布

I have a solution with 2 projects in it. One of the projects can only be run from the other. I want to convert it to DLL, so that end-users cannot directly run it (as it is, they get 2 executables). Is there any straightforward way to do this, without having to copy the entire project?

Thanks,

PM

标签: c# dll
3条回答
疯言疯语
2楼-- · 2019-04-26 20:43

If you mean that you don't want the second executable to be run by the user (only by your program) then make a check in the program (that shouldn't be executed by the user) for an argument or something like that to match, to know that your main program started it.

查看更多
贪生不怕死
3楼-- · 2019-04-26 20:45

If you'd rather play with the .csproj xml, you want to change the OutputType from WinExe (or Exe) to Library, it should be found near the top of the file:

<Project ...>
  <PropertyGroup>
    <ProjectGUID>{YOURGUID-ABCD-0123-4567-0123456789AB}</ProjectGuid>
    <OutputType>Library</OutputType>
...
查看更多
干净又极端
4楼-- · 2019-04-26 20:48

Yes, go to the Project Properties, Application tab and change the Output Type.

查看更多
登录 后发表回答