I want to Power Off a VM, I am able to connect to vm using ConnectToVMWareVIServer method of VIX but I am getting error on when I try to Open the connection.
I am getting an exception Failed to open Virtaul machine..
with inner exception "One of the paramters was invalid"
I am new to VMWare hence I used the c# code mentioned in https://github.com/dblock/vmwaretasks
using (VMWareVirtualHost virtualHost = new VMWareVirtualHost())
{
// connect to a remove (VMWare ESX) virtual machine
virtualHost.ConnectToVMWareVIServer(vmIPAddress, vmUserID, vmPassword);
// open an existing virtual machine
using (VMWareVirtualMachine virtualMachine = virtualHost.Open(vmVMXPath))
{
// power on this virtual machine
virtualMachine.PowerOff();
// wait for VMWare Tools
}
}
Related
I'm trying to get device info using DeviceManager class in C# and i get the folowing error:
The runtime has encountered a fatal error. The address of the error was at 0x7170f7fc, on thread 0x1448. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
Here is my code:
// Create a DeviceManager instance
var deviceManager = new DeviceManager();
// Loop through the list of devices and add the name to the listbox
for (int i = 0; i <= deviceManager.DeviceInfos.Count; i++)
{
// Add the device only if it's a scanner
if (deviceManager.DeviceInfos[i].Type != WiaDeviceType.ScannerDeviceType)
{
continue;
}
// Add the Scanner device to the listbox (the entire DeviceInfos object)
listBox1.Items.Add(new Scanner(deviceManager.DeviceInfos[i]));
}
It started happening after i found a solution online to change the WIA service logon
Services -> Windows Image Acquisition (WIA) right click -> Properties -> Log On tab -> select local System Account and Allow service to interact with desktop.
I tried it, didnt work, so I turned back to "This account" with Local Service user.
Im trying to close an internet explorer window using a dll file in C#.
The attempt is successful if run it in my local pc but if i use the dll in my website im getting this error:
Attached the exact error msg from IISRetrieving the COM class factory for component with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} failed due to the following error.
This is my function to close the window
public void CloseExistingEvar()
{
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
string filename;
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
string[] urlParts = (ie.LocationURL.ToString()).Split('/');
if (urlParts.Contains("E_VAR"))
{
ie.Quit();
}
}
}
}
I dont know how to get the process identity of the IIS7.5 and give permission to this process.
See https://forums.asp.net/t/1093228.aspx?Retrieving+the+COM+class+factory+for+component+with+CLSID+00024500+0000+0000+C000+000000000046+failed+due+to+the+following+error+80070005
Looks like you can add Launch and Activation Permissions for your CLSID, which is the ShellWindows service.
I am using the EdgeDriver for running automation tests on my browser (Edge 38.14393.0.0). My tests are in C#, so I am using the .NET driver:
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Edge;
var options = new EdgeOptions();
options.PageLoadStrategy = EdgePageLoadStrategy.Normal;
RemoteWebDriver driver = return new EdgeDriver(Environment.CurrentDirectory, options, TimeSpan.FromSeconds(60));
driver.SetDocumentSize(new Size(800, 600)); // HERE!
The error
This code is the one I run at the beginning of the test. And it fails at the last line with:
Class Initialization method
Web.TestSuite.UIRendering.RenderingTestSuiteEdge.TestClassInitialize
threw exception. System.InvalidOperationException:
System.InvalidOperationException: A window size operation failed
because the window is not currently available.
With this stack trace:
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:\Projects\webdriver\dotnet\src\webdriver\Remote\RemoteWebDriver.cs: line 1126
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\webdriver\dotnet\src\webdriver\Remote\RemoteWebDriver.cs: line 920
OpenQA.Selenium.Remote.RemoteWindow.set_Size(Size value) in ...
FYI Be aware that I have other tests running on Chrome and IE11 using their respective drivers. When I call SetDocumentSize on those, I get no errors.
Open issues
I could find some open issues related to this problem:
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9340417/
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8778306/
Questions
So, these are my questions:
Has anybody succeeded in setting the window size in Edge?
Is this problem I am hitting a known issue? If so, is it fixed? The referenced issues (which look similar) are still open and no status provided.
Is there any workaround?
Try one of those for C#:
driver.Manage().Window.Size = new Size(1920, 1080);
driver.Manage().Window.Maximize();
Although I encounter that error for different reason (like the one here -> https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10319887/).
Now I kill all process of the driver & edge before each test so hopefully it will be resolved like that:
try
{
foreach (var process in Process.GetProcessesByName("MicrosoftWebDriver"))
{
process.Kill();
}
foreach (var process in Process.GetProcessesByName("MicrosoftEdge"))
{
process.Kill();
}
}
catch (Exception)
{
}
Also if you run them on remote machine via RDP for example it will make the same error when you close the RDP. This is the current workaround that I found for it:
Create a batch file with this code:
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)
Create a desktop shortcut to this file. To do this, right-click the batch
file and select Send to | Desktop (create shortcut).
In the shortcut properties, click Advanced and select Run as administrator.
Now, when you need to disconnect from Remote Desktop, double-click this shortcut on the remote computer (in the Remote Desktop window).
Thanks to https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/keeping-computer-unlocked.html for the script.
This works for me:
driver.manage().window().setSize(new Dimension(1250, 720));
I'm trying to write a very simple client in c# for a named pipe created by hyper-v on windows 8 pro.
The hyper-v named pipe is connected to the com port of a virtual machine.
The code i have written is:
static void PipeClient()
{
NamedPipeClientStream npc = new NamedPipeClientStream(".", "DebianCom1", PipeDirection.InOut);
npc.Connect();
var s = new StreamReader(npc);
var cont = true;
while (cont)
{
Console.Write(s.Read());
}
s.Close();
npc.Close();
}
It throws a System.UnauthorizedAccessException on the instantiation of the named pipe client.
Any pointers?
Try running your C# code as an elevated admin.
A line similar to the following threw the above exception:
PrintServer ps = new PrintServer(#"\\prntsrv");
When I use "Run..." on Windows the address above does work and take me to the list of print jobs so why does the line of code not work?
Apparently, the address \\prntsrv was a DNS alias to \\prntserv and the PrintServer constructor was unable to deal with it. To get around this issue I used the following code (I could also use just the code in the catch block instead and it would work, but preferred not to):
try
{
// Create object to monitor the printer queue
PrintServer printServer = new PrintServer(serverPath);
mPrintQueue = printServer.GetPrintQueue(printerName);
}
catch (PrintServerException ex)
{
// If the problem might be creating the server because the name is an alias
if (ex.Message.Contains("printer name is invalid."))
{
string actualServerHostname = "\\\\" + Dns.GetHostEntry(serverPath.TrimStart('\\')).HostName;
// Create object to monitor the printer queue
PrintServer printServer = new PrintServer(actualServerHostname);
mPrintQueue = printServer.GetPrintQueue(printerName);
// Write to log about the use of a different address
}
else
{
throw;
}
}
hey i was facing similar issue, this is what i observed and made following changes, just try and let me know.
This issue was occuring due to windows feature/role "Print and Document service" is missing on the system. This role is required for managing multiple printers or print servers and migrating printers to and from other windows servers.
To add the role Go To Control Panel->Turn windows feature on or off->click on check box "Print and Document Service"->install.
See with network administrator for installing this rule if you unable to add it.
After adding the role you can able to create print server object and get the all the printqueues on respective server.