VB.net api help

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
Paul7
Posts: 1
Joined: 26. Oct 2017, 03:48

VB.net api help

Post by Paul7 »

Hello all,

First thank you for reading this. My question is this - I'm trying to create a simple automation via the API to setup a virtual machine and create a port forwarding on port80. I've included two bits of code. One that works which is pretty much out of the example and the other which does not and ends in an " Cannot create ActiveX component. "
So either I'm creating the object incorrectly or doing something wrong elsewhere... Any help is greatly appreciated.

Code: Select all

Dim vb As VirtualBox.IVirtualBox
vb = CreateObject("VirtualBox.VirtualBox")
vb.CreateNATNetwork("newNat")
'' This code works

'Add the port forwarding -- This code below does not work :(
Dim vbE As VirtualBox.INATEngine
vbE = CreateObject("VirtualBox.INATEngine") '' This fails with '' Cannot create ActiveX component.''
'vbE.INATEngine.AddRedirect(Of String, VirtualBox.NATProtocol, String, UShort, String, UShort)
vbE.AddRedirect("webfw", VirtualBox.NATProtocol.NATProtocol_TCP, "", 80, "192.168.10.200", 80)
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: VB.net api help

Post by noteirak »

You don't create the INATEngine object yourself, you need to get it from either the vb object if you want to do it for a NAT Network, or at the VM level (mutable one) if you want to do it for the NAT mode of a NIC.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply