I am writing an C# program. I call a method on a COM object that returns
Object. I don't know the type of the object (and reflection just says its a
__ComObject), but I know there is supposed to be Controls property. How can
I call the Controls property without knowing the type of the object?
In VB.NET, you can just do this if Option Explicit is off by just writing
SomeObject.Cont rols. The VB.NET runtime will handle the late binding which,
in this case, includes calling the COM object's IDispatch interface. I
don't see how to do the same thing in C#. The only "late binding" examples
I can find for C# assume you know the type of the object you are calling. 9 7699
You will need to Invoke the method. Check out Invoke in MSDN.
Thanks,
"Scott English" <no****@nospam. com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. I am writing an C# program. I call a method on a COM object that returns Object. I don't know the type of the object (and reflection just says its
a __ComObject), but I know there is supposed to be Controls property. How
can I call the Controls property without knowing the type of the object?
In VB.NET, you can just do this if Option Explicit is off by just writing SomeObject.Cont rols. The VB.NET runtime will handle the late binding
which, in this case, includes calling the COM object's IDispatch interface. I don't see how to do the same thing in C#. The only "late binding"
examples I can find for C# assume you know the type of the object you are calling.
Are you refering to MethodBase.Invo ke? To get a MethodBase object, you must
first know the type of the object the method is on. Am I missing something?
"BuddyHome" <Bu***@onlineho me.com> wrote in message
news:Og******** *****@TK2MSFTNG P10.phx.gbl... You will need to Invoke the method. Check out Invoke in MSDN.
Thanks,
"Scott English" <no****@nospam. com> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. I am writing an C# program. I call a method on a COM object that
returns Object. I don't know the type of the object (and reflection just says
its a __ComObject), but I know there is supposed to be Controls property. How can I call the Controls property without knowing the type of the object?
In VB.NET, you can just do this if Option Explicit is off by just
writing SomeObject.Cont rols. The VB.NET runtime will handle the late binding which, in this case, includes calling the COM object's IDispatch interface. I don't see how to do the same thing in C#. The only "late binding" examples I can find for C# assume you know the type of the object you are
calling.
Sorry Scott,
If are just trying to call a method late bound then see this article. http://groups.google.com/groups?hl=e...%3D10%26sa%3DN
"Scott English" <no****@nospam. com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. Are you refering to MethodBase.Invo ke? To get a MethodBase object, you
must first know the type of the object the method is on. Am I missing
something? "BuddyHome" <Bu***@onlineho me.com> wrote in message news:Og******** *****@TK2MSFTNG P10.phx.gbl... You will need to Invoke the method. Check out Invoke in MSDN.
Thanks,
"Scott English" <no****@nospam. com> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. I am writing an C# program. I call a method on a COM object that returns Object. I don't know the type of the object (and reflection just says its a __ComObject), but I know there is supposed to be Controls property.
How can I call the Controls property without knowing the type of the object?
In VB.NET, you can just do this if Option Explicit is off by just writing SomeObject.Cont rols. The VB.NET runtime will handle the late binding
which, in this case, includes calling the COM object's IDispatch interface.
I don't see how to do the same thing in C#. The only "late binding" examples I can find for C# assume you know the type of the object you are calling.
This article is a lot better. http://my.execpc.com/~gopalan/dotnet/reflection.html
"BuddyHome" <Bu***@onlineho me.com> wrote in message
news:uN******** ******@TK2MSFTN GP12.phx.gbl... Sorry Scott,
If are just trying to call a method late bound then see this article.
http://groups.google.com/groups?hl=e...%3D10%26sa%3DN "Scott English" <no****@nospam. com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. .. Are you refering to MethodBase.Invo ke? To get a MethodBase object, you must first know the type of the object the method is on. Am I missing something? "BuddyHome" <Bu***@onlineho me.com> wrote in message news:Og******** *****@TK2MSFTNG P10.phx.gbl... You will need to Invoke the method. Check out Invoke in MSDN.
Thanks,
"Scott English" <no****@nospam. com> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. > I am writing an C# program. I call a method on a COM object that returns > Object. I don't know the type of the object (and reflection just
says its a > __ComObject), but I know there is supposed to be Controls property. How can > I call the Controls property without knowing the type of the object? > > In VB.NET, you can just do this if Option Explicit is off by just writing > SomeObject.Cont rols. The VB.NET runtime will handle the late
binding which, > in this case, includes calling the COM object's IDispatch interface.
I > don't see how to do the same thing in C#. The only "late binding" examples > I can find for C# assume you know the type of the object you are calling. > >
Well, in that case, you still need to know the type of the object (the
ProgID). In my case, I don't know the type of object or its ProgID, only
that it is suppose to have a "Controls" attribute.
Again, this is no problem for VB.NET. Is C# really inferior to VB.NET in
this regard? Is there really something that VB.NET can do that C# can't?
"BuddyHome" <Bu***@onlineho me.com> wrote in message
news:uN******** ******@TK2MSFTN GP12.phx.gbl... Sorry Scott,
If are just trying to call a method late bound then see this article.
http://groups.google.com/groups?hl=e...%3D10%26sa%3DN "Scott English" <no****@nospam. com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. .. Are you refering to MethodBase.Invo ke? To get a MethodBase object, you must first know the type of the object the method is on. Am I missing something? "BuddyHome" <Bu***@onlineho me.com> wrote in message news:Og******** *****@TK2MSFTNG P10.phx.gbl... You will need to Invoke the method. Check out Invoke in MSDN.
Thanks,
"Scott English" <no****@nospam. com> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. > I am writing an C# program. I call a method on a COM object that returns > Object. I don't know the type of the object (and reflection just
says its a > __ComObject), but I know there is supposed to be Controls property. How can > I call the Controls property without knowing the type of the object? > > In VB.NET, you can just do this if Option Explicit is off by just writing > SomeObject.Cont rols. The VB.NET runtime will handle the late
binding which, > in this case, includes calling the COM object's IDispatch interface.
I > don't see how to do the same thing in C#. The only "late binding" examples > I can find for C# assume you know the type of the object you are calling. > >
well, did you try to make the late-bound call through type System.__ComObj ect? according to the documentation, you should still be able to make such a call through this generic type if your object implements the IDispatch interface
----- Scott English wrote: ----
I am writing an C# program. I call a method on a COM object that return
Object. I don't know the type of the object (and reflection just says its
__ComObject), but I know there is supposed to be Controls property. How ca
I call the Controls property without knowing the type of the object
In VB.NET, you can just do this if Option Explicit is off by just writin
SomeObject.Cont rols. The VB.NET runtime will handle the late binding which
in this case, includes calling the COM object's IDispatch interface.
don't see how to do the same thing in C#. The only "late binding" example
I can find for C# assume you know the type of the object you are calling
Do you mean declaring a variable as System.__ComObj ect? As in
__ComObject o = (__ComObject)so meComObject.Som eMethod();
o.MakeLateBound CallThroughIDis patch();
This doesn't compile. __ComObject isn't a public type. You can't declare a
variable of as __ComObject.
"Daniel Jin" <an*******@disc ussions.microso ft.com> wrote in message
news:85******** *************** ***********@mic rosoft.com... well, did you try to make the late-bound call through type
System.__ComObj ect? according to the documentation, you should still be
able to make such a call through this generic type if your object implements
the IDispatch interface. ----- Scott English wrote: -----
I am writing an C# program. I call a method on a COM object that
returns Object. I don't know the type of the object (and reflection just
says its a __ComObject), but I know there is supposed to be Controls property.
How can I call the Controls property without knowing the type of the object?
In VB.NET, you can just do this if Option Explicit is off by just
writing SomeObject.Cont rols. The VB.NET runtime will handle the late binding
which, in this case, includes calling the COM object's IDispatch interface.
I don't see how to do the same thing in C#. The only "late binding"
examples I can find for C# assume you know the type of the object you are
calling.
Not sure what property you are expecting to get/set, but basically this is
what you have to do using Reflection (and what VB.NET does under the
covers).
object obj = <someCOMObjec t> // your __ComObject reference (Idispatch
interface)
// get property
object prop = obj.GetType().I nvokeMember("", BindingFlags.Ge tProperty, null,
obj, null);
// cast obj to corresponding property type, fi. if a BSTR, cast object to a
string
string s = prop as string;
// set property
obj.GetType().I nvokeMember("", BindingFlags.Se tProperty, null, prop,
...... );
Willy.
"Scott English" <no****@nospam. com> wrote in message
news:OL******** ******@TK2MSFTN GP10.phx.gbl... Do you mean declaring a variable as System.__ComObj ect? As in
__ComObject o = (__ComObject)so meComObject.Som eMethod(); o.MakeLateBound CallThroughIDis patch();
This doesn't compile. __ComObject isn't a public type. You can't declare a variable of as __ComObject.
"Daniel Jin" <an*******@disc ussions.microso ft.com> wrote in message news:85******** *************** ***********@mic rosoft.com... well, did you try to make the late-bound call through type System.__ComObj ect? according to the documentation, you should still be able to make such a call through this generic type if your object implements the IDispatch interface. ----- Scott English wrote: -----
I am writing an C# program. I call a method on a COM object that
returns Object. I don't know the type of the object (and reflection just says its a __ComObject), but I know there is supposed to be Controls property. How can I call the Controls property without knowing the type of the object?
In VB.NET, you can just do this if Option Explicit is off by just writing SomeObject.Cont rols. The VB.NET runtime will handle the late binding which, in this case, includes calling the COM object's IDispatch interface. I don't see how to do the same thing in C#. The only "late binding" examples I can find for C# assume you know the type of the object you are calling.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike MacSween |
last post by:
Had some trouble with Word automation. Sorted it, in the process thought I
would try late binding. Some people reccomend it. So this:
*********************************************************
Public Sub MailMerge(strQuery As String, strTemplate As String)
snip
Dim doc As Word.Document
Dim wrdApp As Word.Application
snip
Set wrdApp = New Word.Application
|
by: JD Kronicz |
last post by:
Hi .. I have an issue I have been beating my head against
the wall on for some time. I am trying to use late
binding for MS graph so that my end users don't have to
worry about having the right version of the MS Graph type
library. Up until now I have been walking them through
the process of setting the references to include their
version of MS Graph library.
My problem is that I can not seem to get the syntax
correct .. or perhaps...
|
by: Composer |
last post by:
I've read many postings about the problem of Access.References.IsBroken
and the consensus seems to be that late binding is the cure-all.
I have a very complex Access application that needs hundreds of lines
of code to format a Word document in a very specific way.
Because my clients have various versions of Word, the problem of broken
references comes up. I wish Microsoft had implemented a reasonable
solution, so that VBA could do...
|
by: Zlatko Matiæ |
last post by:
I was reading about late binding, but I'm not completely sure what is to be
done in order to adjust code to late binding...
For example, I'm not sure if this is correct:
early binding:
Dim ws As DAO.Workspace
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset
|
by: eBob.com |
last post by:
In another thread VJ made me aware of Tag. Fantastic! I've been
wanting this capability for a long time. But it seems that I cannot
use it with Option Strict On. In an event handler I have ...
Private Sub chkbxSelI_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
MsgBox("bingo for number " & sender.Tag.ToString)
End Sub
| |
by: lgbjr |
last post by:
hi All,
I've decided to use Options Strict ON in one of my apps and now I'm trying
to fix a late binding issue. I have 5 integer arrays:
dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as integer
The integers in these arrays are actually pointers to different columns of
data in a text file.
|
by: Tim Roberts |
last post by:
I've been doing COM a long time, but I've just come across a behavior
with late binding that surprises me. VB and VBS are not my normal
milieux, so I'm hoping someone can point me to a document that
describes this.
Here's the setup. We have a COM server, written in Python. For
completeness, here is the script:
----- testserver.py -----
import pythoncom
|
by: GS |
last post by:
I have installed the ms PIA for ofc XP, and followed the article
http://support.microsoft.com/kb/247412/
trying to paste into a worksheet
However I got late binding not allowed errors
....
webOCWraooer,Copy // get the desired data into clapboard
|
by: ADezii |
last post by:
The process of verifying that an Object exists and that a specified Property or Method is valid is called Binding. There are two times when this verification process can take place: during compile time (Early Binding) or run time (Late Binding). When you declare an Object Variable as a specific Data Type, you are using Early Binding so the verification can take place during compile time. When you declare a Variable of the generic Object Data...
|
by: Siv |
last post by:
hi,
I am converting an application that writes to an Excel spreadsheet and the
code trips the "option Strict" that I would like on because the parser says
"option Strict On disallows late binding", I am struggling to understand why
I am tripping this error.
This is the code that causes the problems:
XLApp.Goto("MonthTitleTL") 'Goes to bookmark in sheet
r = XLApp.ActiveCell.Row 'sets variable r equal
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |