on 05-02-2011 10:22 AM
I am using .net connector 3.0 in 64-bit windows environment. I have created a new VS2008(3.5 framework) project and added the sapnco.dll and sapnco_utils.dll into my project reference and build the project, the build is successful and when I execute the application I get tbe error
Could not load file or assembly 'sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I have not written even a single like of code, just trying to execute but it is throwing the error. Need help asap.
Hi;
For my case I would like to mention about how I solve that problem;
I am using Visual Studio 2013 on X64 - based processor.
when I was calling RemoteProcedureCall() method I was gettign exactly the same error.
Solution:
First step I check for the dll that Am I using correct one. By looking the properties of the dll(right click --> Properties ---> Details)
File Description : sapnco.dll for .NET v4.0 on x64.
I was having correct dll for my x64 system. and I check for my refferences in my projects one of ClassLibrary(which I named SAPNco which has SAPNCo.cs and others(CommonStructures,NcoInterface)... ). Refferences was correct . After be sure about these things .
I right clicked the ClassLibrary SAPNco (which refferences sapnco.dll and sapnco_utils) and ---> Properties ---> In Application Tab I select Target Framework : as ".Net Framework 4" and (If you have other class libraries or Windows Applications in your project I applied same thing for them) then I buid the project and Run it. In my case It works like this. I hope It could be helpful for you...
ps .. after succesfull build and run .you can switch to .Net Framework 4.5 again by I right clicking the project --> properties = In Application Tab I select Target Framework : as ".Net Framework 4.5" It workes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Installing Microsoft Visual C++ 2010 Redistributable Package solved this problem for me. I have the SAP .NET Connector 3 x64 - 4.0 installed on Windows Server 2008 R2
http://www.microsoft.com/en-us/download/details.aspx?id=14632
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The above error usually comes when a) trying to mix 32bit and 64bit components, or when b) building the application with type "Any CPU".
In order to avoid a), you need to make sure that all three components (.NET Framework, Visual C++ runtime and NCo 3.0) are installed in the same processor architecture (32bit or 64bit). So for example, if you downloaded the x64 NCo, you also need to have an x64 .NET runtime and the x64 C++ runtime installed on that machine. (Parts of NCo consist of unmanaged C/C++ code, that's the reason why the Visual C++ runtime is required as well.) With .NET Framework 4.0 both versions (32bit and 64bit) are automatically installed, I think. But with earlier .NET versions this was not the case, I think, so you need to make sure you get the right one.
And in order to avoid b), you need to setup your Visual Studio Project for either CPU=x86 or CPU=x64. Using CPU="Any CPU" does not work (again because NCo internally contains unmanaged C/C++ coding).
Hope that helps,
Ulrich
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You mentioned that you are using 32-bit dlls, please check if your environment is 32-bit or 64-bit.
SAP has released different set of dlls for both 32-bit and 64-bit. In order to work with the 64-bit dlls, follow the below steps
1. First pick up the right version of setup file given by SAP (ex: Setup_ntamd64_302.msi)
2. Install the .msi files using the command prompt, normally we just double click and install, but try to execute uing the command prompt. You will get all the required DLL's.
3. Install the Microsoft Visual C# redist packages. I have installed all the versions upto 4.0.
4. Add references sapnco.dll and sapnco_utils.dll into your project.
5. If you directly run the project you will receive the same error "Could not load file or assembly....", so first create a website in IIS for your project and execute the website from that URL.
I have followed the above steps and it worked for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello have you managed to solve your issue? I too am having a similar issue.
I am using .net connector 3.0 in 32-bit windows environment. I have created a new VS2010(4 framework) project and added the sapnco.dll and sapnco_utils.dll into my project reference and build the project, the build is successful and when I execute the application I get tbe error
Could not load file or assembly 'sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I have not written even a single like of code, just trying to execute but it is throwing the error.
Cheers in advance for any help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.