2

We are trying to compile a very old application from 2002 on VB6 at the time (32bits application) in Visual Studio 2022. We need to debug this application and be able to run this app on a Windows 10 machine.

When compiling, we find the following errors, it seems to be a known error by what I found on the web, we tried some workarounds with no success:

enter image description here

Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

We tried the following workarounds so far: enter image description here

It is a .net framework 4 application

From what we understood during our researches, the error seems to be related by incompatibility between x86/x64, but we have no clue on what try to do to fix this problem

Any help is appreciated, much thanks..

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
  • yea do you have a 64 bit of that active control? – Daniel A. White Dec 19 '22 at 19:07
  • Hello Daniel, thanks for your very quick reply...How do we check this? Not sure what is this active control – Victor Lamana Dec 19 '22 at 19:11
  • I think I understood what you're asking. You are talking about 'AxMSWinsockLib.AxWinsock'. We downloaded it from the following link, but its pretty old http://www.ascentive.com/support/new/images/lib/MSWINSCK.OCX – Victor Lamana Dec 19 '22 at 19:21
  • Maybe we need a newer version of it? – Victor Lamana Dec 19 '22 at 19:21
  • I really think you might be out of luck on this one. ActiveX has been out of favour for at least 20years and pretty much obsolete for the last 15. 64 vs 32 bit probably just another nail in the coffin – Hursey Dec 19 '22 at 19:27
  • oh, this is bad....Is rewriting the application the only way? – Victor Lamana Dec 19 '22 at 19:34
  • 3
    @VictorLamana No, it's not the only way and perhaps not even the preferred way. Unless there is a compelling reason I would find a copy of VB6 and use that to debug and compile the app. If this is not possible then I would look into an upgrade tool for VB6 projects. One used to be included in VS2008 and earlier. Maybe you can find this tool someplace. Here's some [more background info](https://stackoverflow.com/questions/14329954/how-to-open-visual-basic-6-program-with-visual-studio-net) on this second option. – Brian M Stafford Dec 19 '22 at 19:57
  • @VictorLamana The 32-bit ActiveX control will cause trouble in VS2022. You may have better luck with older versions of VS or getting the 64-bit ActiveX control if available. – Brian M Stafford Dec 19 '22 at 19:58
  • 3
    If you want to come up to .NET, you need a fairly substantial amount of rework anyway. You might be able to rewrite just the socket parts to use the native .NET socket library instead of the obsolete OCX, and address the normal upgrade stuff separately. Depending on what you're doing with it, it might end up being relatively straightforward find/replace to change over. – Craig Dec 19 '22 at 21:23
  • **1** - You can compile with `/Platform:x86` to force your app to run as 32 bit. **2** - You can put the control into dllhost.exe. Then bitness doesn't matter as it only matters when loading DLLs - https://learn.microsoft.com/en-us/windows/win32/com/registering-the-dll-server-for-surrogate-activation – Lundt Dec 19 '22 at 22:51
  • After a long day of tests yesterday, after restarting the computer we now ran into another error on the app. It seems what we tried yesterday on one of those links I shared earlier partially "fixed" the issue... – Victor Lamana Dec 20 '22 at 11:34
  • New error we are facing.. "Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))" – Victor Lamana Dec 20 '22 at 11:35
  • There's a lot of questions on the ['vb6-migration' tag](https://stackoverflow.com/questions/tagged/vb6-migration) about migrating VB6 to .Net that might be helpful. My specific advice for you is to think about the options based how important this app is and how big the needed changes are. Your options include: [getting a copy of the VB6 IDE](https://stackoverflow.com/questions/8029122/where-can-i-get-a-vb6-ide) and editing the VB6; migrating the app to VS2022; rewriting the app. Rewriting can be manageable for *small* apps, but a massive effort for *large* apps. – MarkJ Dec 20 '22 at 12:32
  • Hello everyone, we had success compiling the app by installing an older version of Visual Studio! We installed visual studio 2010 Professional 64bits and application worked normally and recognized all the components needed... – Victor Lamana Dec 21 '22 at 11:24
  • Maybe the issue is a limitation on newer versions of Visual Studio. Thanks a lot for the help everyone! Much appreciated :) – Victor Lamana Dec 21 '22 at 11:24
  • You can post an answer here with details of what you did, which may help others in the future. – StayOnTarget Dec 21 '22 at 13:44

1 Answers1

1

So after a few days of try and error to fix this problem we managed to successfully build our application only after we installed an older version of Visual Studio (we installed 2010 version)

The prints I posted on the original question also helped during our troubleshooting because they seem to affect the behavior of Visual Studio when compiling, so if you're facing the same error, try that aswell :)

Thanks a lot everyone for the help, was not expecting such fast replies and curiosity in helping!!

  • I've noticed this problem with VS2022 and Windows Forms applications using ActiveX controls. Using Visual Studio 2017 seems to solve the problem. – R.J. Dunnill Dec 26 '22 at 00:57