Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SAP VisualStudio2010
Hi everyone,
 
I am trying to call SAP Gui from a VS2010 C# Windows Forms Application. Below follows my C# source code describing the way i am trying to do it :
 
...
using SAPFEWSELib;
...
 
static class Program
{
 
///
/// The main entry point for the application.
///

 
[STAThread]
 
static void Main()
{
//
// Create the GuiApplication object
//
 
try
{
SAPActive.SapGuiApp =
new GuiApplication(); // <--- But at this point, i get the error message!

}
catch (Exception ex) // Here i trap the error and display the message.
{
 
}
}
}
 
Visual Studio Error Message : Retrieving the COM class factory for component with CLSID {B90F32AD-859E-4EDD-BFAE-C9216849520C} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
 
The setup of my programming environment is as follows :
 
> Windows 7, 64 bit Operating System
> Visual Studio 2010
> .NET 4.0
> SAP Gui Client 7.2
 
As i have searched extensively in many blogs and red a banch of opinions, none of these solved the problem.
 
Here is a list of checks which i have already tried, but still with no success to solve the problem.
 
1. I have checked the Windows Registry. All SAP keys seem to be in place. Especially the key (Class) B90F32AD-859E-4EDD-BFAE-C9216849520C is registered.
 
2. I have checked the Project Settings in VS 2010 for this project. They are all properly set for an x86 bit machine. (as mentioned in many blogs that they so must be!)
 
3. The only one .ocx file which I am currently using in my (VS Project) References is sapfewse.ocx. I have found and added this file as a Reference in my project from the directory C:\program files(x86)\sap\frontend\sapgui\sapfewse.ocx.
 
Does anyone have an idea what might be the cause of the problem or give me a clue what to search? Is this a problem with the version of the Active X Control which i am using (i.e x86/x64)? Am i missing a file as a reference in the using section of the project or is it a matter of access rights?
 
Many thanks in advance.
Posted 10-Mar-13 6:11am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You'll have to declare it like this:
 
public static GuiApplication Application = new GuiApplication();
public static GuiConnection Connection;
public static GuiSession Session;
 
My objects are declared as public because the're Global Objects, also you'll need to use a Session Object and a Connection Object, the way scripting in C# is very very very different from VBS, you'll have to access every GUI resource in a explicit way, here are a few examples on how to do this:
 
((GuiTextField)Session.ActiveWindow.FindByName("RSYST-BNAME", "GuiTextField")).Text = txtUserName.Text; // Set The UserName in the Logon Screen
 
Session.SendCommand(""); // Send Enter
 
((GuiButton)Session.ActiveWindow.FindByName("btn[0]", "GuiButton")).Press();
 
Happy Coding!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 280
1 Jochen Arndt 150
2 Kornfeld Eliyahu Peter 120
3 PIEBALDconsult 110
4 Richard MacCutchan 105
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 29 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100