VMware Cloud Community
DerDerErIst
Contributor
Contributor

Access to VCenter (5.5) with Visual Studio and C# To Create a Application "System.IO.FileNotFoundException"

Hello there,

For a while now im working in a new Company as Software Engineer.

The Company wants me now to Create a simple Software to read out some Datas from our VCenter (Storage Usage, RAM Usage and Average CPU Usage)and save them into a Database.

For this i followed this Tutorial:

https://communities.vmware.com/message/1806388?tstart=0#1806388

However i dont get it to work.

I Installed the latest VMware PowerCLI and insert a Reference in the Visual Studio Project.

VMware.PNG

Now i simply try to make a Connection to the VCenter Server When i Click a Button just for Testing but it isn't working.

The Code is Simple:

Login.PNG

VimClientImpl c = new VimClientImpl();

c.Connect("https://xx.xx.xx.xx/sdk");

c.Login("xxx", "xxx");

if i Start now it throws me out this Exception.

System.IO.FileNotFoundException: "The file or assembly system.runtime, version=4.2.0.0, culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or a dependency on it could not be found. The system cannot find the specified file."

I Also tried different Variants because i found them while Searching in Google:

VimClient c = new VimClientImpl();

c.Connect("https://xx.xx.xx.xx/sdk");

c.Login("xxx", "xxx");

and

VimClient c = new VimClient();

c.Connect("https://xx.xx.xx.xx/sdk");

c.Login("xxx", "xxx");

(Here i cant even Start the Programm because he tells me new VimClient(); is a Abstract class or Interface)

To My Dev System:

Windows 10 Professional
Visual Studio 2019
.Net 3.5 and .Net 4.8
.Net Core

VMware PowerCLI

The Servers are Running on ESXI in a Cluster Environment.

I have no Clue what is wrong or what i can do now.

I have to say that the Documentation from VMware is very Poorly... Especial for someone who never worked before with that.

I hope someone can give me some Hints or Advice whats wrong and what i need to heed for..

Thanks in Advance.

Alex

Reply
0 Kudos
0 Replies