Solved

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

Posted on 2003-12-11
4
603 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

813 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

8 Experts available now in Live!

Get 1:1 Help Now