Solved

Upgrade existing VB6 COM component

Posted on 2010-08-15
6
635 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

770 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