473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Vent on COM Interop (Consuming .NET in VB6)

If you are not in the mood for a rant, then leave now...

I figure most VB.NET programmers have a VB6 background, so I hope you all
don't mind the semi-VB.NET related Interop posting.

Like most of you, we have a large base of VB6 that must be maintained (and
even enhanced), while we are trying to do some new development in VB.NET.

I recently had to make a .NET library I wrote available to my VB6 application.

Considering how easy going from COM to .NET was, going in reverse was a big
pain in the butt.

After reading several articles online (and various section of MSDN help)
I got the gist of the process, but I was most annoyed at the implicit class
interface versus the explicit interface approach. There are tutorial that
explain just slapping a few attributes on the public classes and voila, your
class interface is created. Then two paragraphs later you read a "this is
strongly discouraged in production systems due to client versioning issues".
Don't waste my time explaining the wrong way to do something, I'm busy enough
already.

OK, so I understand that you must explicitly create an Interface to expose
to COM (decorated with a dozen or so attributes after you include the DispIds
on the methods) ... for each and every public class. Then you have to
implement those interfaces through out your assembly (including adding more
attributes to your public classes to hide them from the TypeLibs now that
you are defining them yourself).

But then I hit issues with casting caused by the interfaces versus classes.
I can't just throw an "Implements IMyComInterface.MethodX" onto my MethodX,
because it uses an arguement MyArgForMethodX. But to COM that is an
IMyArgForMethodX instead so my signitures don't match. So now I have to
define the whole bank of interface methods (which mirror my public methods)
and then delegate to my real methods.

You can't tell me that this all could not have been done behind the scenes
when I checked "Register for COM Interop". Or perhaps a wizard or something.
This seems like such a manual process.

And finally, apparently I cannot cast from an array of IMyArgForMethodX to
and array of MyArgForMethodX, so my methods that took arrays now have to have
to explicitly copy from the source array to a temp array and then forward to
my public methods.

Phew. OK, venting done. Well anyway, if anyone has any problems doing
COM Interop you can give me a shout. I think I hit every problem possible
(more than I listed) on my way to getting it to work (which it now does).

Tom
Nov 21 '05 #1
1 1594
You aren't kidding. Interop is a gigantic pain in the behind. According to
the latest edition, it is approximately 1,597 pages of pain in the behind
(.NET and COM The Complete Interoperability Guide).

"tcarvin" <NO***********@lycos.com> wrote in message
news:9f*************************@posting.google.co m...
If you are not in the mood for a rant, then leave now...

I figure most VB.NET programmers have a VB6 background, so I hope you all
don't mind the semi-VB.NET related Interop posting.

Like most of you, we have a large base of VB6 that must be maintained (and
even enhanced), while we are trying to do some new development in VB.NET.

I recently had to make a .NET library I wrote available to my VB6
application.

Considering how easy going from COM to .NET was, going in reverse was a
big
pain in the butt.

After reading several articles online (and various section of MSDN help)
I got the gist of the process, but I was most annoyed at the implicit
class
interface versus the explicit interface approach. There are tutorial that
explain just slapping a few attributes on the public classes and voila,
your
class interface is created. Then two paragraphs later you read a "this is
strongly discouraged in production systems due to client versioning
issues".
Don't waste my time explaining the wrong way to do something, I'm busy
enough
already.

OK, so I understand that you must explicitly create an Interface to expose
to COM (decorated with a dozen or so attributes after you include the
DispIds
on the methods) ... for each and every public class. Then you have to
implement those interfaces through out your assembly (including adding
more
attributes to your public classes to hide them from the TypeLibs now that
you are defining them yourself).

But then I hit issues with casting caused by the interfaces versus
classes.
I can't just throw an "Implements IMyComInterface.MethodX" onto my
MethodX,
because it uses an arguement MyArgForMethodX. But to COM that is an
IMyArgForMethodX instead so my signitures don't match. So now I have to
define the whole bank of interface methods (which mirror my public
methods)
and then delegate to my real methods.

You can't tell me that this all could not have been done behind the scenes
when I checked "Register for COM Interop". Or perhaps a wizard or
something.
This seems like such a manual process.

And finally, apparently I cannot cast from an array of IMyArgForMethodX to
and array of MyArgForMethodX, so my methods that took arrays now have to
have
to explicitly copy from the source array to a temp array and then forward
to
my public methods.

Phew. OK, venting done. Well anyway, if anyone has any problems doing
COM Interop you can give me a shout. I think I hit every problem possible
(more than I listed) on my way to getting it to work (which it now does).

Tom

Nov 21 '05 #2

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

Similar topics

0
by: Mohan Ekambaram | last post by:
Hi, I'm working on a session sharing component that uses db to share the data between asp & aspx pages. Its written in .net & has a wrapper comp in VB6 which can be used to access it from...
1
by: Craig | last post by:
I am having problems getting an ActiveX DLL written in VB6 to call a method in a C# class library component. My C# DLL is called CSharpProject.dll and contains a public class called CSharpClass....
0
by: MarkD | last post by:
I have an ASP.NET (VB.NET) application that calls all VB6 COM DLL via Interop. The DLL uses functionality contained in a Custom OCX Control (Also VB6) that in turn contains a standard TreeView...
6
by: Scott M. Lyon | last post by:
As I mentioned in my other post, I'm attempting to, using COM Interop so I can update existing VB6 code to (for several specific functions) return a Hashtable from a .NET library. I've had...
5
by: Dave | last post by:
I have an existing VC6 ATL COM DLL. It has a number of methods within it that take a byte array as the methods parameters. Here's what the IDL looks like in the VC6 DLL: HRESULT...
4
by: Philip Wagenaar | last post by:
I am trying to create a vb6 activeX dll in .Net. I used the upgrade wizard in vs.net to load my vb6 project and it converted it to vb.net. Now I know that I have to register the DLL from COM...
0
by: Tobester | last post by:
Hi I am having problems accessing a vb6 dll from ASP.Net. The vb6 dll is registered. I have then created an interop file using tlbimp. The interop has been added to the GAC. I can run the...
8
by: John Olbert | last post by:
Subject: Problems with Interop in C# We are having problems using Interop with a Vb6 ActiveX Dll in C# code in Net2 using Vs2005. Below are the signatures of the method that is the problem. It...
1
by: Bhrionn | last post by:
Hello World, I am working on implementing a build for my companies application. The scenario implemeted is producing the error: ‘Class does not support automation or does not support expected...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...

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.