Solved

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

Posted on 2003-12-11
4
597 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
  • 3
4 Comments
 
LVL 7

Accepted Solution

by:
TransBind earned 20 total points
Comment Utility
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
Comment Utility
It works ! Thanks. But why do we cast it ? 'Object' Type diffierence ?
0
 

Author Comment

by:bhchng
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now