VMware {code} Community
Xsaron
Contributor
Contributor

Unable to run the c# samples succesfully (xmlserializer error)

My problem:

Whenever I try to execute a sample with the necessary parameters (at least I think I'm doing it right), I always get an InvalidOperationException error after complaints about the server certificate:

Caught Exception : Name : InvalidOperationException Message : Het XML-document

(7, 52) bevat een fout. Trace : bij System.Xml.Serialization.XmlSerializer.De

serialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents ev

ents)

bij System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, S

tring encodingStyle)

bij System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapCli

entMessage message, WebResponse response, Stream responseStream, Boolean asyncCa

ll)

bij System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String method

Name, Object[] parameters)

bij VimApi.VimService.RetrieveServiceContent(ManagedObjectReference _this)

bij AppUtil.SvcConnection.Connect(String url, String username, String passwor

d) in D:\School\3 MCT 2009-2010\sem 2\stage\werking\vi-sdk-4.0.0-161137\SDK\samp

les\DotNet\cs\AppUtil\SvcConnection.cs:regel 63

bij AppUtil.ServiceUtil.ClientConnect() in D:\School\3 MCT 2009-2010\sem 2\st

age\werking\vi-sdk-4.0.0-161137\SDK\samples\DotNet\cs\AppUtil\ServiceUtil.cs:reg

el 36

Exception running : Connect

and so on ...

I keep getting this error with each of the sample projects. Can someone help me??

My situation:

  • Windows 7 enterprise

  • .NET framework 3.5

  • Visual Studio 2008

  • All the references are in place and the dll's have been build

  • Some other samples that don't come from vmware do work ...

0 Kudos
5 Replies
jeveenj
Enthusiast
Enthusiast

Hi,

Can you please tell us which sample you are running (shipped with VMware SDK) and what arguments you are passing to run the same?

-If you found this information useful, please consider awarding points for Correct or Helpful.
0 Kudos
Xsaron
Contributor
Contributor

Well, I get the error with each sample. But for example when using the connect sample:

connect.exe --url https://192.168.1.88/sdk --username Administrator --password Password

0 Kudos
Serge2409
Contributor
Contributor

Hi,

I am having exactly the same error with any C# sample.

Connect.exe --url http://192.168.1.25/sdk --username user --password pass
...
ServiceUtil.cs:line 36
Exception running : Connect
Caught Exception :  Name : InvalidOperationException Message : There is an error in XML document (7, 52). 
Trace :
   at AppUtil.ServiceUtil.ClientConnect() in C:\SDK\samples\DotNet\cs\AppUtil\ServiceUtil.cs:line 44
   at AppUtil.AppUtil.connect() in C:\SDK\samples\DotNet\cs\AppUtil\AppUtil.cs:line 652
...

I have ESX 4.0 update01, 208167, installed inside a virtual machine for testing. And it appears to be working OK. At least I can connect to it using the vSphere Client and change the settings there, browse performance, etc. but all samples fail to connect.

0 Kudos
Xsaron
Contributor
Contributor

Anyone? This is an issue here!

0 Kudos
Xsaron
Contributor
Contributor

Okay, it took me a while but I figured out that it has to do with the dll's used. The samples (if I'm not mistaken), make standard use of the VimService2005 and VimService2005.XmlSerializers dll's. But I'm using esx 4 update 1 and as I've read, you have to use the other dll's (starting with vim25) in stead of these ! So I added reference to the vim25 dll's and changed the 'using VimApi' to 'using Vim25Api' in the classes and then as good as all the samples worked. I know that it's a little dirty to work like this but it worked so I'm happy.

I hope that the other ones in this topic with the same problem, get it fixed this way.

grts

0 Kudos