C# make a DLL out of a Windows Forms Project

2019-04-26 19:53发布

问题:

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

回答1:

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



回答2:

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>
...


回答3:

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.



标签: c# dll