Click here to Skip to main content
13,004,446 members (74,572 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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

/// <summary>
/// The main entry point for the application.


static void Main()
// Create the GuiApplication object

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 5:11am

1 solution

Rate this: bad
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!
Hari prakash R 28-Mar-17 1:17am
you are using FindByName...if i use FindById i got this error while run time...

The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)).

Please help to solve the error.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170627.1 | Last Updated 29 May 2013
Copyright © CodeProject, 1999-2017
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