Avatar of RIAS
RIAS
Flag for United Kingdom of Great Britain and Northern Ireland asked on

32 bit COM to 64 bit

Hi,
Any suggestions on converting 32 bit COM to 64 bit. I am using visual studio 2019.  The 32 bit COM is in vb 6.0. Basically I am converting a vb6 project to .  net.

thanks
Visual Basic.NET.NET ProgrammingVisual Basic Classic

Avatar of undefined
Last Comment
Peter Hutchison

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Wilder1626

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
RIAS

ASKER
Thanks. But any suggestion on the COM.
Wilder1626

This link can help a little more: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-configure-projects-to-target-platforms?view=vs-2019

To configure a project to target a 64-bit platform

  1. On the menu bar, choose Build > Configuration Manager.
  2. In the Active solution platform list, choose a 64-bit platform for the solution to target, and then choose the Close button.

Hope this can answer some of your questions.
RIAS

ASKER
Thanks.So if I add a reference to 32 bit COM in . net project and build it with 64 bit, will my COM object get converted to 64 bit?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Wilder1626

I don't think so. you would need build your .NET project as 64bit if you want it to correctly load a 64-bit DLL on a 64bit machine.
Wilder1626

You can also use "Any CPU" , but you will need to supply both 32 and 64 bit version of the DLL.
Adding a new link you can also look at:
Migrating 32-bit Managed Code to 64-bit​​​

Éric Moreau

do you have a specific need to go 64-bits? Not all applications benefit from switching to 64-bits.

old COM components are 32-bits only. Newer components (like Crystal Reports) come in 2 flavors (32 and 64 bits). If you reference Office, you also might have issues mixing 32 & 64 bits.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
RIAS

ASKER
Helo Eric,
Thanks for your comment. Yes, its a business decision to go 64 bit as there are few libraries which are compatible with only 64 bit. So, its beyond my scope to change the decision. Hence all COM has to be migrated to 64 bit. 
Éric Moreau

One thing that is not clear to me: are you rewriting all your VB6 projects in .Net?

if that's the case, there is no worry about 32/64 bits as you can target 64 bits in every project.

if you keep some old VB6 COM DLL and want to use them in .Net 64-bits, have a look at Calling 64 bit code from a 32 bit VB6 application (mobilize.net) 
RIAS

ASKER
Thanks Eric, planning to rewrite the vb6 to C#. 
Your help has saved me hundreds of hours of internet surfing.
fblack61
RIAS

ASKER
Eric,
We are planning to convert 32 bit COM to 64 bit. Any suggestions? 
RIAS

ASKER
The COM surrogate will not work as the idea is to convert everything to 64 bit.
Éric Moreau

Not sure to get the question then. Are you looking for something that will automatically convert your old VB6 code into C#? I am not aware of such a tool. When .Net was first introduced (20 years ago!), Microsoft was providing a tool that was trying to convert VB6 code to VB.Net code but even that was not producing good code!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Peter Hutchison

Another company has taken over conversions of old Visual Basic/Studio code to .NET at https://www.mobilize.net/products/app-migrations/vbuc.

As Eric says, the best way is is re-compile as either Any CPU or just 64 bit. When updating code, I make sure all references use .NET assemblies/libraries where possible and avoid old COM calls e.g. System.IO for file system calls, System.sql.sqlclient instead of ADO, DOA, DirectoryServices instead of ActiveDS.IADs calls.