I created a Windows service project and later decided to change it's output type to class library so I could include the service class in another project which would create the .exe to be installed as a service. But now when I try to build the first project it fails with the error:
/platform:anycpu32bitpreferred is not a valid setting for option /target:library or /target:module
How can I fix this?
Find the line <Prefer32Bit>true</Prefer32Bit> and change the value "true" to "false". There might be more than one depending how many different configurations have been set up. Removed true from one of the project. It worked. But not sure how this entry was added to that particular project. Can you please explain with more detail...
You can use any version of Visual Studio to target both 32-bit and 64-bit platforms. The Configuration Manager provides a way for you to quickly add a new platform to target with your project. If you select one of the platforms included with Visual Studio, the properties for your project are modified to build your project for the selected platform.
So for OP sounds like the configuration is correct for the Debug build, but your target platform may not match the platform specified in your test configuration profile. If you experience this issue please check that the target platform in the build properties for your project match the configuration platform.
How can I fix this? This is an older blog post, but it suggests editing the .csproj file directly and removing <Prefer32bit>true</Prefer32bit>, and then unloading and reloading the project in the solution. Show activity on this post.
Try to
unload project (right click in solution explorer)
edit <projectName>.csproj
(right click in solution explorer)
remove <Prefer32Bit>true</Prefer32Bit>
reload project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With