cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Connector works for me, but not where I deploy the program.

Former Member
0 Kudos

Greetings,

I am developing a C# .NET application using Visual Studio 2005. I've created an SAPProxy class, and am using the .NET connector 2.0 dlls. I connect, call my RFC, get my data, and all is well -- on my machine.

When I deploy my code to another machine (with SAP.Connector.dll and SAP.Connector.Rfc.dll), and the user runs my application, it blows-out with this error:

                            • Exception Text **************

System.NullReferenceException: Object reference not set to an instance of an object.

at AutomatedPullLogic.Form1.getDetailsWorker_DoWork(Object sender, DoWorkEventArgs e)

at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)

at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

                            • Loaded Assemblies **************

mscorlib

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

-


AutomatedPullLogic

Assembly Version: 1.0.0.0

Win32 Version: 1.0.0.0

CodeBase: file:///C:/Program%20Files/AutomatedPullLogic/AutomatedPullLogic.exe

-


System.Windows.Forms

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

-


System

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll

-


System.Drawing

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

-


System.Core

Assembly Version: 3.5.0.0

Win32 Version: 3.5.30729.1 built by: SP

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll

-


System.Configuration

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

-


System.Xml

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll

-


SAP.Connector

Assembly Version: 2.0.0.0

Win32 Version: 2.0.0.23

CodeBase: file:///C:/Program%20Files/AutomatedPullLogic/SAP.Connector.DLL

-


System.Web.Services

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Web.Services/2.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll

-


System.Security

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Security/2.0.0.0__b03f5f7f11d50a3a/System.Security.dll

-


Here is my proxy:

public class SAPProxy : SAPClient

{

// SAP client constructors.

public SAPProxy() { }

public SAPProxy(string connectionString) : base(connectionString) { }

public SAPProxy(IContainer container) : base(container) { }

public SAPProxy(Destination destination) : base(destination) { }

// Set the SAP proxy information within the function formal parameter list.

[RfcMethod(AbapName = "Z_DEMO_CALL")]

public virtual void Z_DEMO_CALL(

[RfcParameter(AbapName = "IF_DRAWING_NUMBER", RfcType = RFCTYPE.RFCTYPE_CHAR, Optional = false, Direction = RFCINOUT.IN, Length = 25)]

string drawing,

[RfcParameter(AbapName = "IF_PROJECT", RfcType = RFCTYPE.RFCTYPE_CHAR, Optional = false, Direction = RFCINOUT.IN, Length = 24)]

string project,

[RfcParameter(AbapName = "IF_DRAW_REV", RfcType = RFCTYPE.RFCTYPE_CHAR, Optional = false, Direction = RFCINOUT.IN, Length = 2)]

string revision,

[RfcParameter(AbapName = "EF_REV_LAST_RLSD", RfcType = RFCTYPE.RFCTYPE_CHAR, Optional = false, Direction = RFCINOUT.OUT, Length = 2)]

out string rel_rev,

[RfcParameter(AbapName = "EF_REV_RLSD", RfcType = RFCTYPE.RFCTYPE_CHAR, Optional = false, Direction = RFCINOUT.OUT, Length = 1)]

out string rel_flag,

[RfcParameter(AbapName = "EF_MSG", RfcType = RFCTYPE.RFCTYPE_CHAR, Optional = false, Direction = RFCINOUT.OUT, Length = 220)]

out string message,

[RfcParameter(AbapName = "EF_MSGTY", RfcType = RFCTYPE.RFCTYPE_CHAR, Optional = false, Direction = RFCINOUT.OUT, Length = 2)]

out string type)

{

// Call the SAP function, and then set the return data.

object[] results = this.SAPInvoke("Z_DEMO_CALL", new object[] { drawing, project, revision });

rel_rev = (string)results[0];

rel_flag = (string)results[1];

message = (string)results[2];

type = (string)results[3];

}

}

Here is how I call it:

private string GetSAPInfo(string drawing, string revision, string hull, string option)

{

// Default the released revision.

string relRev = "";

try

{

// Create the SAP destination object.

using (Destination dest = new Destination())

{

// Setup the SAP destination overhead properties.

dest.SAPGui = 0;

dest.UseSoap = false;

dest.AbapDebug = false;

dest.Trace = Convert.ToBoolean(IniReader.GetValue("SAP {0} DEFAULTS", "RFC_TRACE"));

// Setup the SAP destination logon properties.

dest.Client = Convert.ToInt16(IniReader.GetValue("SAP DEFAULTS", "CLIENT")); dest.Language = IniReader.GetValue("SAP DEFAULTS", "LANG");

dest.AppServerHost = IniReader.GetValue("SAP DEFAULTS", "ASHOST"); dest.SystemNumber = Convert.ToInt16(IniReader.GetValue("SAP DEFAULTS", "SYSNR"));

dest.Type = IniReader.GetValue("SAP DEFAULTS", "TYPE");

dest.Username = IniReader.GetValue("PROXY USERS AND PASSWORDS", "SAPUSR");

dest.Password = IniReader.GetValueDecrypted("PROXY USERS AND PASSWORDS", "SAPPWD");

// Create the SAP proxy instance that has our RFC function.

using (SAPProxy proxy = new SAPProxy(dest))

{

// Call the SAP function.

string flag = "", message = "", type = "";

proxy.Z_DEMO_CALL(

drawing, hull, revision,

out relRev, out flag, out message, out type);

}

}

}

catch (RfcException rfcEx)

{

// Throw a general exception.

throw new Exception(rfcEx.Message + "\n\n" + rfcEx.StackTrace);

}

catch (NullReferenceException nullEx)

{

// Throw a general exception.

throw new Exception(nullEx.Message + "\n\n" + nullEx.StackTrace);

}

catch (Exception ex)

{

// Throw a general exception.

throw new Exception(ex.Message + "\n\n" + ex.StackTrace);

}

return relRev;

}

Any help would be greatly appreciated.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Terence Burns

Software Development Analyst 4

SE Organization B4566E, CATIA Group

Building 802-2, 26

(757) 688-4524 Tel

(757) 380-3632 Fax

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I'm a dummy. It wasn't an SAP hookup problem. I was having a password decryption problem.