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
IMyArgForMethod X 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 IMyArgForMethod X 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 1 1611
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 Interoperabilit y Guide).
"tcarvin" <NO***********@ lycos.com> wrote in message
news:9f******** *************** **@posting.goog le.com... 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 IMyArgForMethod X 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 IMyArgForMethod X 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 classic ASP pages. The pblm
is i also need to refer this Wrapper component in a VB6 Proj 'A' for
classic asp pages & i'm using the .net Session codebase in the asp.net
pages.
This is what i tried... & this is the pblm i got...
|
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. In this class is a single public method that
returns the string "Hello
from C sharp".
My VB6 ActiveX DLL references the C# DLL (CSharpProject.dll) using the
|
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 control. The
Custom OCX is not used for visual purposes, but has some functionality
that we require (hence hosting an OCX in a DLL).
Everything worked fine until we installed the latest service pack for
each respective windows operating system:...
|
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 very little luck processing the Hashtable itself in VB6 (I can add
a reference to the project so it knows what a Hashtable is, but I'm not
having much luck looping through all objects in the Hashtable), so I decided
to try a different idea.
|
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 GetSystemConfig( SAFEARRAY(unsigned char) *pData, long *retval);
As you can see it is a byte array (SAFEARRAY)
In the VB.NET object browser the the prototype looks like this:
| |
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 interop. I can check the box in vs.net on
the compiler tab to do this.
But how do I register my DLL for COM interop on another machine?
|
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 code through a windows application with everything
working fine. In this situation I have:
|
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 is the last argument (e.g., "out obj" in C#) that is returned
corrupted. It should be an array of integers. In one simple test App this
argument does return an array of integers reliably. In the actual App it
returns one or two integer arrays but...
|
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 interface' when I try to run the RegFree COM interop application from a clients machine.
The application works fine for all development machines when run locally or from the network.
The application is run from the network so - the component is not...
|
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: 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,...
| |
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |