Solved

Cannot implicitly convert type 'object' to 'QUANTUMAUTOMATIONLib.Browse2Class'

Posted on 2003-12-11
4
610 Views
Last Modified: 2012-05-04
I am converting the following code from VB to C#. It works in VB but seems to be have some problem in C#. It is the limitation in C# ? Any expert advice ?


public frmMain()
{
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
                  
      // Declare global object
      SessionClass objSession;
      QDataAccessClass objDataAccess;
      Browse2Class objBrowser;
                  
      // Get a Session Object.
      objSession = new SessionClass();
                  
      // Get a DataAccess Object.
      objDataAccess = new QDataAccessClass();

      // Get the Browser Object from Session.
      objBrowser = objSession.Browser;   // <-- **** ERROR ****

      // Give the Session Pointer to the DataAccess object.
      objDataAccess.SetSession(objSession);

      }
0
Comment
Question by:bhchng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 7

Accepted Solution

by:
TransBind earned 20 total points
ID: 9925871
perhaps you need to cast it: examples

int newInt = (int) stuff [0];
string newString = (string) stuff [1];
Button button2 = (Button) stuff [2];

objBrowser = (Browse2Class)objSession.Browser;  




0
 

Author Comment

by:bhchng
ID: 9925980
It works ! Thanks. But why do we cast it ? 'Object' Type diffierence ?
0
 

Author Comment

by:bhchng
ID: 9925993
It does not give an error when compiling. But when running the program, it says "Specified cast is not valid". Doesnt seems to be the solution.
0
 

Author Comment

by:bhchng
ID: 9926173
Code in Visual Basic:

'=======================================================================
'Synopsis:      Declare global variables & objects
'-----------------------------------------------------------------------
Option Explicit
Dim objSession As QUANTUMAUTOMATIONLib.Session
Dim WithEvents objDataAccess As QUANTUMAUTOMATIONLib.QDataAccess
Dim objBrowser As QUANTUMAUTOMATIONLib.Browse2
Dim objQualityHelper As QUANTUMAUTOMATIONLib.QQualityHelper


'=======================================================================
'Synopsis:      User Interface Message Handlers
'-----------------------------------------------------------------------


'=======================================================================
'Synopsis:      Create global objects and set it ready for use
'-----------------------------------------------------------------------
Private Sub Form_Load()
' Get a session object for Live DataAccess
Set objSession = New QUANTUMAUTOMATIONLib.Session

' Get a QualityHelper object
Set objQualityHelper = New QUANTUMAUTOMATIONLib.QQualityHelper

' Get the Browser Object from Session.
Set objBrowser = objSession.Browser

End Sub
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question