473,494 Members | 2,223 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to access a COM object from .NET

If I have accessed a COM object in this manner:

Type MyType = Type.GetTypeFromProgID("someCOMobject");
Object ThisObj = Activator.CreateInstance(MyType);
object returnedItems = MyType.InvokeMember("someFunction",
System.Reflection.BindingFlags.InvokeMethod, null, ThisObj, null);

and I happen to know that returnedItems is a
Microsoft.VisualBasic.Collection object, then what is the correct way to
access the individual items in that collection? Doing

foreach (object item in (Collection) returnedItems)

causes an System.InvalidCastException exception.
Nov 17 '05 #1
1 1474
If you have a COM object (i.e. you have a dll that contains COM components)
why not create an interop assembly.

Check the following out:

http://msdn.microsoft.com/library/de...priinterop.asp

HTH

Ollie Riches

"Robert Rotstein" <rr*******@verizon.net> wrote in message
news:lG_Xe.8427$T55.3556@trndny06...
If I have accessed a COM object in this manner:

Type MyType = Type.GetTypeFromProgID("someCOMobject");
Object ThisObj = Activator.CreateInstance(MyType);
object returnedItems = MyType.InvokeMember("someFunction",
System.Reflection.BindingFlags.InvokeMethod, null, ThisObj, null);

and I happen to know that returnedItems is a
Microsoft.VisualBasic.Collection object, then what is the correct way to
access the individual items in that collection? Doing

foreach (object item in (Collection) returnedItems)

causes an System.InvalidCastException exception.

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
23846
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how...
0
4040
by: goermezer | last post by:
Hello, I have some problems to automate a CAD (computer aided design) Software called CATIA V5 from Dassault Systemes. CATIA V5 has a builtin VB-Editor like Word, Excel, … and registers itself...
11
1817
by: WindAndWaves | last post by:
Hi Gurus I have recently discovered references in the VB section of MS Access, however, when choosing references, I noticed that there are more than who knows how many options. How and/or where...
20
3291
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
8
25328
by: Jerry | last post by:
I have an off-the-shelf app that uses an Access database as its backend. One of the tables contains a field with an "OLE Object" datatype. I'm writing some reports against this database, and I...
17
26502
by: Pam Ammond | last post by:
I need to use Microsoft Access Automation within a Visual Studio 2003 program written in C# for Windows Forms. When a button is clicked in my VS.NET program, I want it to run a Microsoft Access...
2
18908
by: Brent Burkart | last post by:
I am trying to send an email using SMTP server through IIS. I am recieving the following error. Access is denied. Description: An unhandled exception occurred during the execution of the...
3
2082
by: Shawn | last post by:
Hi. In my application I store information about the user in the session object. Since I'm storing sensitive information I encrypt it before storing and decrypt it when I need to use it again. The...
2
14099
by: Dean Slindee | last post by:
Anybody written code in VB.NET to: 1) show a print preview window of reports already written and stored in an Access 2002 database; or 2) execute the print of a report stored in an Access 2002...
52
9913
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
0
7119
marktang
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,...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7195
jinu1996
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...
0
7367
tracyyun
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...
0
5453
agi2029
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,...
0
4579
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...
0
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.