VB.net api help

Discussion about using the VirtualBox API, Tutorials, Samples.

VB.net api help

Postby Paul7 » 30. Oct 2017, 02:05

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   Expand viewCollapse view
Dim vb As VirtualBox.IVirtualBox
vb = CreateObject("VirtualBox.VirtualBox")
'' 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, "", 80)
Posts: 1
Joined: 26. Oct 2017, 03:48

Re: VB.net api help

Postby noteirak » 20. Nov 2017, 20:53

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://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
Site Moderator
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Return to The VirtualBox API

Who is online

Users browsing this forum: No registered users and 2 guests