cancel
Showing results for 
Search instead for 
Did you mean: 

Single Signon using C#

rasmuswulff_jensen
Active Contributor
0 Kudos

Hi, Have anyone been able to make and use a single sign-on connection using C#?

I successfully make the connection til the client and just after that I make the single-signon (As the UI-reference exsampel does). This single-signon is succesfully, but when I use the SAPBobs-company which I connected, in an event the company-object is corrupted (A Simple debugging fails for some reason)...

Anyone been able to use this feature with C#

Accepted Solutions (0)

Answers (1)

Answers (1)

rasmuswulff_jensen
Active Contributor
0 Kudos

This exsampel show the problems (see the comments in code on the event-handler method)

public SAPbobsCOM.Company c = new SAPbobsCOM.Company();

public SAPbouiCOM.Application app;

public SAPbouiCOM.SboGuiApi gui = new SAPbouiCOM.SboGuiApiClass();

private void Form1_Load(object sender, System.EventArgs e) {

//Connect til SAP

try {

//Henter connection-string fra commandolinie og laver connect til SBO (gui)

gui.Connect(Environment.GetCommandLineArgs()[1]);

try {

//Vælger SBO (Hvis flere kørende)

app = gui.GetApplication(-1);

}

catch(Exception exp) {

throw new Exception("Fejl under oprettelse af Application: "+exp.Message);

}

}

catch {

throw new Exception("SBO er ikke startet. Start det og prøv igen");

}

string cookie = c.GetContextCookie();

string conStr = app.Company.GetConnectionContext(cookie);

if(c.Connected) {

c.Disconnect();

}

if(c.SetSboLoginContext(conStr) == 0) {

c.Connect();

}

//Call methos that use company

normal_method();

//Registration Eventhandlers

app.MenuEvent+=new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(app_MenuEvent);

}

private void app_MenuEvent(ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent) {

BubbleEvent = false;

//At this point c is corrupted (In a watch all properties is "error: cannot obtain value string")

if(c.Connected) {

MessageBox.Show("Test");

}

//Also if i try this alle properties in c2's watch is "<error: an exception of type: {System.InvalidCastException} occurred> SAPbobsCOM.BoSuppLangs"

SAPbobsCOM.Company c2 = new SAPbobsCOM.Company();

}

private void normal_method() {

if(c.Connected) {

MessageBox.Show("Test2");

}

}

rasmuswulff_jensen
Active Contributor
0 Kudos

Solved the problem now.... I Reinstalled the SDK and for some reason it did the trick

Former Member
0 Kudos

Hi Rasmus,

I was wondering have you been able to succesfully use the DI SDK at the same you use the UI SDK in C#? I have no problems using the UI SDK but if I try to any objects inside the DI I get an IQuery interface problem. I can succesfully use the DI SDK when not using the UI SDK. Is anyone using both SDKs sucessfully at the same time in C# using version 6.5?

Lita

rasmuswulff_jensen
Active Contributor
0 Kudos

Yes.... DI and UI together works as it should for me now Have you made the single-signon as it is done in the samples? .... I use the following versions: SDK 6.5 SP0 R20 along with SBO Client 6.5 SP1 (There is no SDK with the SP1 yet)...

Former Member
0 Kudos

Thanks Rasmus, I've upgraded to version 6.5 SPO R20 and everything now works fine!