Win Service project won't Build after switching to Any CPU config
Asked Answered
N

3

10

I'm trying to find a fix for my problem. After changing my .net 4.0 C# Win Service project to Any CPU/Release build configuration, I am getting this compile time error:

Cannot specify /main if building a module or library

It identifies the offending file as "CSC" and the project generating it is my Service project (not my accompanying code library in the solution). I've looked through the project file and configuration editor settings yet haven't been able to identify the source to my problem.

Anyone else ever experience this show stopping problem?

Noleta answered 19/7, 2010 at 14:8 Comment(0)
N
27

Fixed! I'll include the solution in case anyone else comes across this strange build behavior. I found a forum thread on MSDN that had the solution to the problem. In the project file I removed the value between the <StartupObject> tags and left it blank. Now builds successfully without the previous error.

Noleta answered 19/7, 2010 at 14:41 Comment(2)
Both the ways it worked for me, <startUpObject> </startUpObject> can added by editing project file or class assembly which contains "packages.config".Reparable
for those who don't know what is project file. It its the .csproj fileJacquetta
I
5

This fix worked for me by toggling the Output Type. Do not know why, but seems to clear the CS2017 error. Then build works. No changes to code were made.

  1. Project > Application > Output type: Class Library
  2. Build - good build, but does not run
  3. Project > Application > Output type: Console Application
  4. Build - good build, code runs
Immobilize answered 13/9, 2018 at 3:57 Comment(1)
this will work vise-versa also, make a build console => class library and class library => consoleReparable
E
0

I had the same problem with .net MAUI project targeting Android and Ios. The problem occurred while adjusting the app version number. Removing the value between the StartupObject in .csproj, as as noted above, solved the problem.

Elamitic answered 3/7 at 8:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.