VMware

This Question is Answered

2 "helpful" answers available (6 pts)
4 Replies Last post: May 21, 2007 12:38 PM by zerovoid  

VixCom/VIX VMWare Server Exceptions: GetErrorText and Connect posted: May 21, 2007 10:39 AM

Click to view zerovoid's profile Novice 27 posts since
May 21, 2007
This post has a few questions.

What is error code 6 when trying to connect?
I get this error returned in everything C, C#, VB, VBScript/WSH, Perl
Why am I having these exceptions in VixCom for GetErrorText?
Why do my programs crash when compiled with DevC++ and VC++2005 but run fine with VC++6 (except error 6 returned)?
Is this a bug in VixCom/Vix?
Has anyone had any luck with VixCom or Vix on VMWare Server?
If yes, can you please post your code or a link to a project source?
Language is not a problem as long as it uses VIX.
The other APIs do not support some of the functionality I am seeking.

Environment:
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)

Visual C Sharp (C#)

C Sharp (C#) Code
Source at http://www.buriproject.info/vix/c%20sharp%20GetErrorText.7z
[code]
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);
}
}
}
[/code]

C Sharp(C#) Error ScreenShot
http://www.buriproject.info/vix/c%20sharp%20GetErrorText.png

Error Text
[code]
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()
[/code]

Visual Basic (VB)
VB Code
Source at http://www.buriproject.info/vix/vb%20GetErrorText.7z
[code]
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
[/code]

VB Error ScreenShot
http://www.buriproject.info/vix/vb%20GetErrorText.png

VB Error Text
[code]
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()
[/code]

Click to view mattrich's profile Expert 510 posts since
Nov 29, 2006
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.

Developer Social Media

Communities