Link to home
Start Free TrialLog in
Avatar of Rias
RiasFlag 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
ASKER CERTIFIED SOLUTION
Avatar of Wilder1626
Wilder1626
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rias

ASKER

Thanks. But any suggestion on the COM.
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.
Avatar of 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 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.
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​​​

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.
Avatar of 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. 
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) 
Avatar of Rias

ASKER

Thanks Eric, planning to rewrite the vb6 to C#. 
Avatar of Rias

ASKER

Eric,
We are planning to convert 32 bit COM to 64 bit. Any suggestions? 
Avatar of Rias

ASKER

The COM surrogate will not work as the idea is to convert everything to 64 bit.
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!
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.