Could not load file or assembly "Interop.VBRUN" when using a vb6 ocx control in vb.net

Viewed 270

Context

I need to create a vb6 ocx control and use it in vb.net. Essentially, it is a collection of methods for drawing on the old vb6 PictureBox.

Once the .ocx file was created, I recorded it with the usual regsvr32 procedure and imported it into the Visual Studio toolbox. I can add the new control to the form without any problems, and it runs.

Problem

If I add a button and in its click sub I call a function of the control (which should, trivially, draw a line on the picturebox) an exception is thrown:

System.IO.FileNotFoundException

Could not load file or assembly 'Interop.VBRUN, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

Attempts

  • I tried copying all the control code into a new project and exporting the ocx again. No result.
  • I tried to use the control on Visual Studio 2008 and on Visual Studio 2019 (both on windows XP and on Windows 10). No result.
  • I tried to comment out most of the ocx control code and leave only a few methods active. No result.
  • I tried to use the control in a vb6 project. It works perfectly.
  • I tried trying to import this Interop.VBRUN as a reference, but I couldn't find it anywhere.

Notes

I use Vb6 on a virtual machine with Windows XP. I've tested the ocx in Visual Studio (2008 and 2019) on this virtual machine and and outside of it (on Windows 10). My settings:

  • destination Framework = .NET Framework 4;
  • destination CPU = x86

I also searched on stackoverflow and around the web for a solution: there are very few similar results, but none with a valid solution.

Questions

How can I resolve this problem? What is this Interop.VBRUN? Is the problem caused by the code (which I should then rewrite) or something else?

1 Answers

I used aximp.exe to put a wrapper around a vb6 *.ocx. Maybe give it a try?

Related