2
votes

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
When you say "no result" - what does that mean? I think you meant, those trials made no difference ie the same error resulted?StayOnTarget
Interop.x is a managed COM interop assembly for the COM package x. I think it's most likely created automatically by running tlbimp on a type library, so look for it in the output folder for your build.Craig
Craig's comment is correct. You should look for file 'Interop.VBRUN.dll' and add a reference to it in your projectStayOnTarget
@UuDdLrLrSs yes: "no result" stands for "this made no difference and the error is still here"Calaf
AxInterop. files are created as a .NET "wrapper" for OCX files. Interop. files are the same, but for regular DLLs. In general if you had a VB6 DLL abc.dll and you referenced that from a .NET project, the file Interop.abc.dll would be created automatically, and also added as a reference. This is just FYI; it doesn't explain why the VBRUN file is missing.StayOnTarget

1 Answers

0
votes

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