【发布时间】:2015-11-12 13:08:13
【问题描述】:
我正在尝试使用 InitiateFileTransferToGuest 方法将文件发送到 VM。不幸的是,我被卡住了。下面是相关代码,其中 VClient 是已经成功连接的 VimClient:
GuestOperationsManager VMOpsManager = new GuestOperationsManager(VClient, VClient.ServiceContent.GuestOperationsManager);
GuestFileManager VMFileManager = new GuestFileManager(VClient, VClient.ServiceContent.FileManager);
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, VClient.ServiceContent.AuthorizationManager);
NamePasswordAuthentication Auth = new NamePasswordAuthentication()
{
Username = "username",
Password = "password",
InteractiveSession = false
};
VMAuthManager.ValidateCredentialsInGuest(CurrentVM.MoRef, Auth);
System.IO.FileInfo FileToTransfer = new System.IO.FileInfo("C:\\userlist.txt");
GuestFileAttributes GFA = new GuestFileAttributes()
{
AccessTime = FileToTransfer.LastAccessTimeUtc,
ModificationTime = FileToTransfer.LastWriteTimeUtc
};
string TransferOutput = VMFileManager.InitiateFileTransferToGuest(CurrentVM.MoRef, Auth, "C:\\userlist.txt", GFA, FileToTransfer.Length, false);
进入 ValidateCredentialsInGuest 方法时出现第一个错误。我收到这条消息:
VMware.Vim.dll 中出现“VMware.Vim.VimException”类型的未处理异常附加信息:请求引用了意外或未知类型。
如果我删除该验证,我会在尝试运行 InitiateFileTransferToGuest 时收到相同的错误。老实说,我一直在浏览 API 文档、VMware 论坛和很多地方的帖子。我看到的唯一一段代码是在 Java 和 Perl 中发布的,但 API 实现与 C# 有点不同。知道在哪里看吗? 谢谢!
【问题讨论】: