cancel
Showing results for 
Search instead for 
Did you mean: 

Error when using SAP .Net Connector NCO 3.0 with WCF service

Former Member
0 Kudos

Hello

I am trying to use .Net connector (NCO 3.0) with WCF service and recieving the following Inner Exception

*"exePath must be specified when not running inside a stand alone exe."*

The same code works perfectly when used in a Console application.

Am I missing something in the configuration.

Below is the stack trace for the same


at SAP.Middleware.Connector.RfcDestinationManager.GetDestination(String destinationName)
   at MaintainPersonalData.MaintainPersonnelData.GetPersonnelDetails(Int32 EmpNo, DateTime BeginDate, DateTime EndDate) in *********************************************************************\MaintainPersonnelData.svc.cs:line 26
   at SyncInvokeGetPersonnelDetails(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

We have this exact same problem. It seems to me there's an issue with how the connector is looking for its config information. As far as we know it should be looking in the web.config file of the hosting site when WCF is in IIS but this doesn't seem to be happening - it's looking for a config file related to the config assembly which it won't find.

As with the previous poster, we have connected to SAP with no problem from a console application. We're investigating hosting our WCF service in a windows service in the hope that solves the problem. Sure seems like something isn't right with the connector as working with .NET config locations across Windows/web is pretty basic stuff.

Pareshkumar, did you make any progress?

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

I try to create a WCF service with sapnco 3.0 but when i launch my site, i have this error :

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 use sapnco 64 bits on windows server 2008 64 bits. I set the platform target on 64 bits.

But i still have this error message.

Somebody have any idea to solve this error ?

Thanks in advance

Finally, I've changed the platform target and the dll to 32 bits.

Edited by: Iveusse on Dec 15, 2011 3:17 PM

Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

the next patch level (NCo 3.0.4) will provide a fix for this problem, so the workaround will no longer be necessary then. At the moment we don't have a planned release date yet for 3.0.4, but it'll probably be before the end of the year.

Ulrich

Former Member
0 Kudos

Hi

I have downloaded the new patch 3.0.5 for NCO. Will test it with all of my WCF services and post the results. Thanks for the update and sorry for late response.

Former Member
0 Kudos

OK, I just found out some more. Looking at the actual code of the connector, I see where I think the problem is:


// SAP.Middleware.Connector.RfcConfigParameters
using System;
using System.Configuration;
using System.Reflection;
using System.Web;
using System.Web.Configuration;
static RfcConfigParameters()
{
	Configuration configuration = null;
	if (HttpContext.Current != null)
	{
		configuration = WebConfigurationManager.OpenWebConfiguration("~");
	}
	else
	{
		configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
	}
	ConfigurationSectionGroup sectionGroup = configuration.GetSectionGroup("SAP.Middleware.Connector");

Our code is falling over when it instantiates RfcConfigParameters and this constructor code seems to explain why - as far as I can tell, with WCF there will be no HttpContext so it acts as though this is a Windows (exe) app. That of course doesn't work as this is a web app and all our config is in web.config. Microsoft info suggests the code should be using RequestContext instead - Link: http://msdn.microsoft.com/en-us/library/aa702682.aspx

Looks like .NET Connector v3.0 is not compatible with WCF.

As an aside, we don't even want to pickup config directly from the config file (something the connector documentation says it supports) yet despite our not explicitly asking to do so the config class tries to get to config. If it weren't for that and the resulting exception we would be good to go since we're providing all the config we need directly. Not good.

Anyone on these boards have any NCO 3.0 experience?

Former Member
0 Kudos

Good find Richard123456, I have seen this issue as well, but it's interesting to see the underlying issue that caused it. I found a workaround by using the ASP.NET Compatibility Mode to force the WCF solution to read the HttpContext.

There are instructions for how to enable compatibility mode at the MSDN link you had included in your post (http://msdn.microsoft.com/en-us/library/aa702682.aspx).

Basically, it involves adding the serviceHostingEnvironment tag and setting the compatibility mode to true as seen below.

<system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>

It has a couple drawbacks, you lose some of the flexibility in that you can only use this with IIS and HTTP, but it's better than nothing at all.

HTH!

Former Member
0 Kudos

Thanks Richard and Ken

It always relieves me thinking I am not alone on the boat. The current documentation with .Net Connector is very primitive.

I will try the workaround and post back results.

Former Member
0 Kudos

Hi Ken

The workaround did helped and now I can use the WCF service. I am stil leeping this question open just to check if we can get root cause for the error.

Thanks again !!!

Former Member
0 Kudos

Great solution! Thanks a lot.

I'm exactly on the same scenario WCF Service using SAP NCO Connector 3.0.

stefan_offermann
Explorer
0 Kudos

> I'm exactly on the same scenario WCF Service using SAP NCO Connector 3.0.

same here, I also had trouble running a WCF service using NCo 3, updating to the newest assemblies of version 3.0.5 fixed my bugs