Page 1 of 1

VB.net api help

Posted: 30. Oct 2017, 02:05
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)

Re: VB.net api help

Posted: 20. Nov 2017, 20:53
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.