This post has a few questions.
What is error code 6 when trying to connect?[/b]
I get this error returned in everything C, C#, VB, VBScript/WSH, Perl
Why am I having these exceptions in VixCom for GetErrorText?[/b]
Why do my programs crash when compiled with DevC++ and VC+2005 but run fine with VC+6[/b] (except error 6 returned)[b]?[/b]
Is this a bug in VixCom/Vix?[/b]
Has anyone had any luck with VixCom or Vix on VMWare Server?[/b]
If yes, can you please post your code or a link to a project source?[/b]
Language is not a problem as long as it uses VIX.
The other APIs do not support some of the functionality I am seeking.
WinXPSP2
VMWare Server 1.0.3 (even though it has been tried on older versions and different machines)
Vix API 1.1
Tried in various languages (C#, VB, VBScript, C)
[u]Visual C Sharp (C#)[/u][/b]
Source at http://www.buriproject.info/vix/c%20sharp%20GetErrorText.7z
using System;
using System.Collections.Generic;
using System.Text;
using VixCOM;
namespace VIXTest
{
class Program
{
static void Main(string[] args)
{
VixCOM.VixLib lib = new VixCOM.VixLib();
Console.WriteLine("Connecting...");
VixCOM.IJob job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER, "", 0, "", "", 0, null, null);
object[] data = \{ VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE };
object results = null;
ulong err = job.Wait((VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), ref results);
if (lib.ErrorIndicatesFailure(err))
{
ushort errCode = lib.ErrorCode(err);
string errMsg;
errMsg = lib.GetErrorText(err, null);
Console.WriteLine("Error: " + errCode.ToString() + " : " + errMsg);
}
exit(true);
}
static void exit()
{
exit(false);
}
static void exit(bool prompt)
{
if (prompt)
{
Console.Write("Press Any Key To Exit");
Console.ReadKey();
}
System.Environment.Exit(-1);
}
}
}
C Sharp(C#) Error ScreenShot[/b]
http://www.buriproject.info/vix/c%20sharp%20GetErrorText.png
System.Runtime.InteropServices.COMException was unhandled
Message="The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"
Source="Interop.VixCOM"
ErrorCode=-2147417851
StackTrace:
at VixCOM.VixLibClass.GetErrorText(UInt64 err, String locale)
at VIXTest.Program.Main(String[] args) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\VIXTest\VIXTest\Program.cs:line 23
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Source at http://www.buriproject.info/vix/vb%20GetErrorText.7z
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim VixLibA As New VixCOM.VixLib
Dim job = VixLibA.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER, Nothing, Nothing, Nothing, Nothing, 0, Nothing, Nothing)
Dim results = Nothing
Dim err = job.Wait((VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), results)
If VixLibA.ErrorIndicatesFailure(err) Then
Dim errMsg = VixLibA.GetErrorText(err, Nothing)
MsgBox("Error: " & err.ToString() & " : " & errMsg)
End If
End Sub
End Class
http://www.buriproject.info/vix/vb%20GetErrorText.png
System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="Interop.VixCOM"
StackTrace:
at VixCOM.VixLibClass.GetErrorText(UInt64 err, String locale)
at VixCom_Test.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\VixCom Test\VixCom Test\Form1.vb:line 10
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at VixCom_Test.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Similar to the response that my colleague gave in the thread "VixHost_Connect Problem", the issue that there is a version mismatch issue.
Error code 6 is 'not supported'.
You're having an exception when you call GetErrorText() because when Connect() failed, not all of the required libraries were loaded, so VIX is having difficulties looking up the error string. We're looking into ways to make sure that this doesn't happen in future releases.
You should be able to get this to work by explicitly passing 1 as the first argument to Connect().
Just to be clear, only functions from the version 1.0 of the VIX API are supported with VMware Server.
I would like to also mention this is a 32bit environment.
This forum needs an edit post function.
Similar to the response that my colleague gave in the thread "VixHost_Connect Problem", the issue that there is a version mismatch issue.
Error code 6 is 'not supported'.
You're having an exception when you call GetErrorText() because when Connect() failed, not all of the required libraries were loaded, so VIX is having difficulties looking up the error string. We're looking into ways to make sure that this doesn't happen in future releases.
You should be able to get this to work by explicitly passing 1 as the first argument to Connect().
Just to be clear, only functions from the version 1.0 of the VIX API are supported with VMware Server.
Wonderful thanks...
For anyone using the code above...
Set the version to 1 and be sure to assign the propertyIDs as an array.
eg (VB).
job = VixLibA.Connect(1, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER, Nothing, Nothing, Nothing, Nothing, 0, Nothing, Nothing)
Dim propertyIDS() As Object = \{VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE}
Dim err = job.Wait(propertyIDS, results)
This also solved my problem with Visual C+, unfortunately not DevC+
The C code connect example[/b]
#include "stdafx.h"
#include <vix.h>
int _tmain(int argc, _TCHAR* argv[])
{
VixHandle jobHandle = VIX_INVALID_HANDLE;
VixHandle hostHandle = VIX_INVALID_HANDLE;
VixError err = VIX_OK;
jobHandle = VixHost_Connect(1,VIX_SERVICEPROVIDER_VMWARE_SERVER,NULL,0,NULL,NULL,0,VIX_INVALID_HANDLE,NULL,NULL);
err = VixJob_Wait(jobHandle,
VIX_PROPERTY_JOB_RESULT_HANDLE,
&hostHandle,
VIX_PROPERTY_NONE);
if (VIX_OK != err) {
printf("\nError: %i",err);
printf("\n%s\n",Vix_GetErrorText(err,NULL));
goto abort;
} else {
printf("connection success!\n");
}
Vix_ReleaseHandle(jobHandle);
abort:
return 0;
}
