Solved

Upgrade existing VB6 COM component

Posted on 2010-08-15
6
629 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:TerryDean
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for your help!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 49
matchUp  challenge 9 71
Best way to parse out a json string in VB6? 10 70
Adding to a VBA? 6 46
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now