Closed smartmeter closed 8 years ago
Hello smartmeter,
sapnco and sapnco_utils are developed and published by SAP, I cannot change the build target of any of them.
You'll have to choose the processor architecture you are going to use in your build.
hmm, I'm not sure why you closed this, I am using your lib and trying to help get something resolved! :-1:
Anyways, I did something to overcome this by checking the build architecture and then including the correct lib. Hope this helps, since the target is not in your control
public static ushort GetPEArchitecture(string pFilePath)
{
ushort architecture = 0;
try
{
using (System.IO.FileStream fStream = new System.IO.FileStream(pFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
using (System.IO.BinaryReader bReader = new System.IO.BinaryReader(fStream))
{
if (bReader.ReadUInt16() == 23117) //check the MZ signature
{
fStream.Seek(0x3A, System.IO.SeekOrigin.Current); //seek to e_lfanew.
fStream.Seek(bReader.ReadUInt32(), System.IO.SeekOrigin.Begin); //seek to the start of the NT header.
if (bReader.ReadUInt32() == 17744) //check the PE\0\0 signature.
{
fStream.Seek(20, System.IO.SeekOrigin.Current); //seek past the file header,
architecture = bReader.ReadUInt16(); //read the magic number of the optional header.
}
}
}
}
}
catch (Exception) { /* TODO: Any exception handling you want to do, personally I just take 0 as a sign of failure */}
//if architecture returns 0, there has been an error.
return architecture;
}
}
0x10B - PE32 format. 0x20B - PE32+ format.
here is a inky http://j.mp/1NchttT
I closed because you've asked something I could not do. But feel free to share here how you managed to solve, I really appreciate that 👍🏼
However, IMHO, that seems like a hack to me. Why can't you just change your project to target x64 architecture? Will your app ever run on x86?
Btw, if you need to target both x86 and x64 you can try using sharpsaprfc.soap. It has no external dependency, so it's build targeting MSIL.
Hello I have the same issue
Hello, I am getting runtime errors because of the build target.
I have tried both,
1 - using Nuget 2 - building with the non specific targets both are not giving me the right solution, this does not build because its asking for dependencies.
Can you please help.
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23, processorArchitecture=x86", "x86".
This mismatch causes runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.