Could not load file or assembly "sapnco" or one of its dependencies. An attempt was made to load a program with an incorrect format
I have this error when I am using SAP.NET Connector 3.0 x64. I couldn't find any solution on stackoverflow, so I would like to share here for others who stuck with the same problem as me.
Run> Regedit
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\1X.0\WebProjects
Change Use64BitIISExpress
from 0
to 1
Restart Visual Studio and IISExpress.
You can try browsing / configuring your service via IIS and installing appPool.Net 4.0. I hope this solves the sapnco dll problem.
I had a similar problem with x86
I set Target Platform from "any" to "x86" in Project / Properties and fixed the problem.
I had a similar problem with VS 2017 and AnyCPU option.
To fix the problem, I will disable the checkbox Prefer 32-bit
in the build properties of the project.