Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Upgrade existing VB6 COM component

Posted on 2010-08-15
6
Medium Priority
?
648 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 2000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

604 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