473,657 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM object (no type library) - how do I access the interface from VB.NET?


I have a COM object, which implements straightforward ly the IDataObject
interface. It seems this isn't the same IDataObject interface we now have
with .NET. Basically, the COM object implements low level interfaces. It
does not have a type library. We use it freely with our unmanaged C++
projects. What I would like to do is load or create one of these objects in
VB.NET, but I cannot seem to do it.

I've tried:

Dim theObject As Object

theObject = GetObject ( "c:\gas.tgw " ) * gas.tgw is a file-type we
associated with the COM object

but how do I get the IDataObject interface from theObject?

Is it possible to use basic low-level COM interfaces with VB.NET?

Any answers would be much appreciated.
Nov 20 '05 #1
11 4183

"Robin Tucker" <r.******@therm oteknix.com> wrote in message
news:bk******** ***********@new s.demon.co.uk.. .

I have a COM object, which implements straightforward ly the IDataObject
interface. It seems this isn't the same IDataObject interface we now have
with .NET. Basically, the COM object implements low level interfaces. It
does not have a type library. We use it freely with our unmanaged C++
projects. What I would like to do is load or create one of these objects in VB.NET, but I cannot seem to do it.

I've tried:

Dim theObject As Object

theObject = GetObject ( "c:\gas.tgw " ) * gas.tgw is a file-type we
associated with the COM object

but how do I get the IDataObject interface from theObject?

Is it possible to use basic low-level COM interfaces with VB.NET?


Sure, you can use the COM interfaces but you need a type library. Then you
need to generate an Interop Assembly.

The type library may be embedded in the dll, or you could create it if you
have the MSIL interface definitions.

David
Nov 20 '05 #2
So I definately need a type library? There is no way we can generate one
for this program - it implements IDataObject in COM but it isn't an
automation object. I would have thought it would just be a case of finding
the interface using "FindInterfaces ". But obviously not. In this case,
VB.NET can't be properly supporting com I guess, if it only supports objects
with type libs.

"David Browne" <davidbaxterbro wne no potted me**@hotmail.co m> wrote in
message news:O6******** ******@TK2MSFTN GP12.phx.gbl...

"Robin Tucker" <r.******@therm oteknix.com> wrote in message
news:bk******** ***********@new s.demon.co.uk.. .

I have a COM object, which implements straightforward ly the IDataObject
interface. It seems this isn't the same IDataObject interface we now have with .NET. Basically, the COM object implements low level interfaces. It does not have a type library. We use it freely with our unmanaged C++
projects. What I would like to do is load or create one of these
objects in
VB.NET, but I cannot seem to do it.

I've tried:

Dim theObject As Object

theObject = GetObject ( "c:\gas.tgw " ) * gas.tgw is a file-type we
associated with the COM object

but how do I get the IDataObject interface from theObject?

Is it possible to use basic low-level COM interfaces with VB.NET?


Sure, you can use the COM interfaces but you need a type library. Then you
need to generate an Interop Assembly.

The type library may be embedded in the dll, or you could create it if you
have the MSIL interface definitions.

David

Nov 20 '05 #3

"Robin Tucker" <r.******@therm oteknix.com> wrote in message
news:bk******** ***********@new s.demon.co.uk.. .
So I definately need a type library? There is no way we can generate one
for this program - it implements IDataObject in COM but it isn't an
automation object. I would have thought it would just be a case of finding the interface using "FindInterfaces ". But obviously not. In this case,
VB.NET can't be properly supporting com I guess, if it only supports objects with type libs.


How do the unmanaged C++ programs use this component?

Do they have the interface definitions?
Do they use IDispach?

David

Nov 20 '05 #4

Something like this - we use CoGetObject - this is part of a method that
gets data from the object and converts it into a DIB for rendering. As you
can see, I may have my work cut-out in VB.NET! (but vb might get ditched if
I cannot do things like this).
// Connect to the object.
IDataObjectPtr image;
TryMethod(CoGet Object(display_ name, 0, IID_IDataObject , (void**)&image) );
// First try to get a DIB.
FORMATETC fe = { CF_DIB, 0, DVASPECT_CONTEN T, index, TYMED_HGLOBAL };
if (SUCCEEDED(imag e->GetData(&fe, &sm)))
{



Nov 20 '05 #5
We implement the following interfaces on the object:

IClientSecurity
IDataObject
IDispatch
IMarshal
IMultiQI
IOleContainer
IOleInPlaceActi veObject
IOleInPlaceObje ct
IOleItemContain er
IOleObject
IOleWindow
IParseDisplayNa me
IPersist
IPersistFile
IPersistStorage
IProxyManager
IUnknown

"David Browne" <davidbaxterbro wne no potted me**@hotmail.co m> wrote in
message news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..

"Robin Tucker" <r.******@therm oteknix.com> wrote in message
news:bk******** ***********@new s.demon.co.uk.. .
So I definately need a type library? There is no way we can generate one for this program - it implements IDataObject in COM but it isn't an
automation object. I would have thought it would just be a case of

finding
the interface using "FindInterfaces ". But obviously not. In this case,
VB.NET can't be properly supporting com I guess, if it only supports

objects
with type libs.


How do the unmanaged C++ programs use this component?

Do they have the interface definitions?
Do they use IDispach?

David

Nov 20 '05 #6
Hi Robin,

Have you tried hauling in your component by adding a Reference to your
project? When I tried that (a long time ago) it said something like "There's
no blah, blah, would you like me to create an Interop wrapper?". Yes please
and off you go. It may not be clever enough to map all your functions but then
again, it may.

Regards,
Fergus
MVP [Windows Start button, Shutdown dialogue]
Nov 20 '05 #7
No chance! It says it isn't a valid COM component or assembly, which, in a
sense, I guess is true. The component won't show up in the COM tab because
it doesn't have a typelib and it isn't an automation object. My guess is it
just isn't possible and I will either have to create a C++ source file that
will do it for me and somehow links into VB.NET or I will ditch VB.NET and
go back to plain old C++, ATL etc.

"Fergus Cooney" <fi******@tesco .net> wrote in message
news:Or******** ******@tk2msftn gp13.phx.gbl...
Hi Robin,

Have you tried hauling in your component by adding a Reference to your
project? When I tried that (a long time ago) it said something like "There's no blah, blah, would you like me to create an Interop wrapper?". Yes please and off you go. It may not be clever enough to map all your functions but then again, it may.

Regards,
Fergus
MVP [Windows Start button, Shutdown dialogue]

Nov 20 '05 #8
Hi Robin,

Shame about that. I'd go the C++ wrapper and then get a .NET wrapper. And
then you can write some wrapper classes around it in VB.NET just so it feels
really warm and cosy. :-)

Go back?? You can't go back. Or maybe I'm just biased.

Best wishes,
Fergus
MVP [Windows Start button, Shutdown dialogue]
Nov 20 '05 #9
What I don't understand about this situation is the files will happily embed
in Word documents (Insert->Object) - so I must be doing something wrong!

I don't want to go back to C++ - luckily I'm just experimenting with VB.NET
at the start of a project which, after much deliberation, we decided would
be best written in VB.NET. Of course, provided our existing COM components
were compatible. Designing a nice looking UI is a pain in the ass with ATL.
I am going to jump out of the office window if I have to do that.

"Fergus Cooney" <fi******@tesco .net> wrote in message
news:ud******** ******@TK2MSFTN GP12.phx.gbl...
Hi Robin,

Shame about that. I'd go the C++ wrapper and then get a .NET wrapper. And then you can write some wrapper classes around it in VB.NET just so it feels really warm and cosy. :-)

Go back?? You can't go back. Or maybe I'm just biased.

Best wishes,
Fergus
MVP [Windows Start button, Shutdown dialogue]

Nov 20 '05 #10

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

Similar topics

0
3248
by: Grant | last post by:
I've cross-posted this in the COM+ group as well - apologies if that's a no-no. But the problem might be caused by either... interop or just plain COMAdmin. ============================================= I've got a VB.NET app that is trying to access the Component Services catalog. The first class method installs a new component at a specified location. The second method searches for a specified component and deletes it.
0
1411
by: Tom Z. | last post by:
Hi All, I'm trying to make an assembly in C# to use as a COM server. I'm building as normal and ruinning regasm at the end. Everything is generally working, except that I'm having a problem hiding some generic implementation base classes from the type library exporter. Here is a code sample: -------------------------------------------------------
1
3579
by: Tom Z. | last post by:
Hi All, I'm trying to make an assembly in C# to use as a COM server. I'm building as normal and ruinning regasm at the end. Everything is generally working, except that I'm having a problem hiding some generic implementation base classes from the type library exporter. Here is a code sample: -------------------------------------------------------
1
2458
by: Ping | last post by:
Hi, i am trying to : dim db As database and i have Access 2002. The object type "database" is not in the list and error message is "type mismatching " when run. i am wondering if the "database" object type is replaced by some other object or i did not install the office XP correctly.
6
9411
by: Programmer | last post by:
I am making a project in which i have one interface ITest, and a class which is implementing that interface. I am making object of that class using object obj=Activator.CreateInstance("TypeName"); ITest objITest =(ITest) obj; It is giving error explicit typecasting not allowed
0
2527
by: Erwan | last post by:
I have a strange (but very blocking) result when using the smtpmail class from an ASPX page : here is the (very simple !) code... '-------------------------------------------------- mail.To = "el@illico.fr" mail.From = "el@illico.fr" mail.Subject = "test envoi de mail" mail.Body = "test envoi de mail"
6
1904
by: Picho | last post by:
Hi all. I have a webservice and a windows app. both of them reference the same class library called WebServiceTest.Core that defines a class called Class1. the webservice exposes a method that looks like this: public WebServiceTest.Core.Class1 GetClass1()
2
3131
by: nigel.stephens | last post by:
nigel.stephens@parasolit.­co.uk Nov 24, 10:04 am show options Newsgroups: microsoft.public.dotnet.framework.interop From: "nigel.steph...@parasolit.co.uk" <nigel.steph...@parasolit.co.uk> - Find messages by this author Date: 24 Nov 2005 02:04:50 -0800 Local: Thurs, Nov 24 2005 10:04 am Subject: Mehods not showing in COM (CCW) interface of .NET assembly Reply | Reply to Author | Forward | Print | Individual Message | Show
7
11938
by: Martin Robins | last post by:
I am currently looking to be able to read information from Active Directory into a data warehouse using a C# solution. I have been able to access the active directory, and I have been able to return "DirectoryEntry" objects within the path that I specify (either using the DirectoryEnrtry.Children or using the DirectorySearcher class) and all started well and dandy! Now the problem; some of the properties of the DirectoryEntry objects being...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
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 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...
0
8610
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 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...
0
4168
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...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.