Solved

Upgrade existing VB6 COM component

Posted on 2010-08-15
6
636 Views
Last Modified: 2013-11-26
Hi,

I need to change an existing in-process COM DLL used by multiple visual basic applications.  The COM DLL was written in Visual Basic 6 nearly 10 years ago by some consultants and the code was never provided or is no longer available.  The problem is that the code has hard coded values that need to be changed.  

The functionality of the code can easily be reproduced.  So the question is what is the best way to create a replacement component?  It would be ideal not to require that all the existing application be changed or recompiled to use the new component.  

I was thinking of recreating the component in visual basic 6 and setting it to be binary compatible with the existing component.  In that way it should be able to be deployed without affecting existing applications.  But I have a longer term goal to migrate the entire application to .NET and this functionality would need to be migrated at some point.

I briefly looked at the Microsoft website for guidance and saw the recommendation to upgrade using COM interop.  But can that be made binary compatible with the existing component?  

Thanks for you advise and help!
0
Comment
Question by:TerryDean
  • 3
  • 3
6 Comments
 
LVL 22

Expert Comment

by:danaseaman
ID: 33442836
You should be able to create a new component setting Binary Compatibility against the old DLL.
In order to not break existing Exe or require recompiling do the following:
1. All Public exposed Methods, Properties, Events must be identical to original including Parameter types.
2. ByVal and ByRef for Params must be idnetical to original.
3. You can add Private Functions without problems.

Anything that deviates from above will bump the Major Version number of the component.
Any new Public Methods, Properties, Events will bump the Minor Version numer of the component.

It is easy enough to tell if you are successfull. Just check the new component with OleView or similar to get the TLB Versiuon info.
At top of OleView screen you should see something like this:

// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: UniSuiteLite.ocx

[
  uuid(A9E51769-CEC2-4332-85BE-145DF0C9C6A2),
  version(1.0),

If the version is the same as original you should be OK.


0
 

Author Comment

by:TerryDean
ID: 33470200
Thanks for the information!  What about re-writing the component in .NET?  Is it possible to maintain binary compatibility to the original component in .NET?  Thanks again!
0
 
LVL 22

Expert Comment

by:danaseaman
ID: 33471152
Not sure if you could use a Vb6 created OCX as binary compatibility for .Net component.
You could change the GUID of a OCX post-build to match the original though.
See my post "Public Function ReplaceGUIDInFile" at:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_25001798.html?sfQueryTermInfo=1+10+30+strguidtomemori


0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:TerryDean
ID: 33491688
I got started attempting to replicate the functionality of the existing com component using VB6 as you suggested.  I figured that I could upgrade to .NET later.  But ran into a couple of problems.  I opened the original TLB in OleView (great suggestion by the way!) which gave me all the functionality I need to replicate.  But there are a couple of properties that I cannot get to replicate in VB6.  The first is "HRESULT _NewEnum([out, retval] IUnknown** retval);"  and the second is "HRESULT Type([out, retval] MTypeConstants* retval);"  VB6 will not let me create a property named _NewEnum or Type.  Is there some way to get VB6 to accept these names or something I can do later to the resulting IDL or TLB to change them?

Thanks again for your help!

0
 
LVL 22

Accepted Solution

by:
danaseaman earned 500 total points
ID: 33491989
What are you enumerating?
For NewEmum is usually something like this for a collection:
You neet to set Procedure ID to -4 via advanced properties.

Public Property Get NewEnum() As IUnknown
   Set NewEnum = mCol.[_NewEnum]
End Property

http://www.bigresource.com/Tracker/Track-vb-JfLxGzuKgs/
http://bytes.com/topic/visual-basic/answers/168907-newenum-diffeculties

Don't know about the Type Property/Method.
Is it possible to upload the Dll? If not direct to this site you can try MediaFire or similar.


0
 

Author Closing Comment

by:TerryDean
ID: 33530204
Thanks for your help!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question