private void button2_Click(object sender, RoutedEventArgs e)
{
WebClient wb = new WebClient();
wb.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wb_DownloadStringCompleted);
wb.DownloadStringAsync(new Uri("http://weather.yahooapis.com/forecastrss?w=2502265"));
}
void wb_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
XElement xmlResult = XElement.Parse(e.Result);
}
This is code i have used. I am getting an error "Unable to connect to the remote server".
I am able to connect to internet from the IE browser in the emulator.
Suggest a suitable solution.
Did you try to restart your emulator ? Because it happens to me : I got this error with the emulator but none with a simple console programm. After a restart of VS, it works.
I cannot reproduce your problem with the code you have provided. Are you sure you're not stuck behind a firewall or something that blocks your request? Try using Fiddler (or a product like it) to see whats going on.
To allow the Emulator in friewall.
Open Control Panel\System and Security\Windows Firewall\Allowed Programs
Click on "Change Settings" to enable "Allow another program"
Browse - > "C:\Program Files (x86)\Microsoft XDE\1.0\XDE.exe"
Tick Public / Private Network or both as you are connected to internet.
Related
I am trying to launch it via simple code when hyperlink is clicked and using its deeplink: slack:\\open
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Hyperlink hyperlink = (Hyperlink)sender;
Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.AbsoluteUri));
}
Error I am getting on Slack is below:
This can be reproduced if you ran Powershell as admin and launch the app and try to login to web it won't connect to desktop app.
I sure know there's a workaround if you click on "Copy Sign-In Key" but I want to avoid that error message.
Potential cause is that C# process launches Slack via System instead of using current User.
I am trying to explore using impersonation but could not seem to find the right code to be used.
Below is an example of how I open Zoom and Teams
private void button2_Click_1(object sender, EventArgs e)
{
string user = System.Windows.Forms.SystemInformation.UserName.ToString();
System.Diagnostics.Process.Start("C:/Users/" + user + "/AppData/Local/Microsoft/Teams/current/Teams.exe");
}
private void button1_Click_1(object sender, EventArgs e)
{
string user = System.Windows.Forms.SystemInformation.UserName.ToString();
System.Diagnostics.Process.Start("C:/Users/" + user + "/AppData/Roaming/Zoom/bin/Zoom.exe");
}
Note: Unlike Zoom and Teams that when installed they create a folder where we find all the installation supplements, but Whiteboard does not have any folder against these supplements. That's why it's very difficult to open it from my application in C#
Microsoft Whiteboard is a store app.
Here's a Post about How to open Microsoft Store apps from Command Prompt?
You can find these apps here:
shell:AppsFolder
From CMD you can start it with
explorer.exe shell:appsFolder\Microsoft.Whiteboard_8wekyb3d8bbwe!Whiteboard
From code it can be started this way:
System.Diagnostics.Process.Start(#"C:\Windows\explorer.exe shell:appsFolder\Microsoft.Whiteboard_8wekyb3d8bbwe!Whiteboard");
Another example can be found here:
https://notepad.onghu.com/2020/launch-win10-app-from-cmdline/
From the code it seems like you just want to start the process, not run it directly on your winform app. By default, applications downloaded from Microsoft Store are stored in C:/Program Files/WindowsApps.
I am trying to do some kind of Installer where i need to install a WinService.
What I currently do is adding the Service.exe as Resource to my Installer Project, then write all bytes of it to a specific folder.
After successfully writing the file to a specified folder, i install the service using ManagedInstallerClass.InstallHelper
The problem i've with it now is that the ManagedInstallerClass.InstallHelper is somehow locking the Service executable, so i cannot delete/overwrite the file (from outside or inside the program), because it's blocked while the Installer Application is running, beginning from first ManagedInstallerClass.InstallHelper call on the Service file.
Here is my code which causes this problem.
private void button1_Click(object sender, EventArgs e)
{
try
{
UninstallAndStopServiceIfExist("RDPBFP_Service");
}
catch (Exception)
{
MessageBox.Show("Service not running, so cannot stop it!");
}
Thread.Sleep(1000);
//File.Delete(#"C:\RDPBFP\RDP-Bruteforce-Protector_Service.exe");
Directory.CreateDirectory(#"C:\RDPBFP");
File.WriteAllBytes(#"C:\RDPBFP\RDPBFP_Service.exe", Properties.Resources.RDPBFP_Service);
try
{
ManagedInstallerClass.InstallHelper(new string[] { #"C:\RDPBFP\RDPBFP_Service.exe" });
}
catch (Exception i_ex)
{
MessageBox.Show(i_ex.Message);
}
//StartService("RDPBFP_Service");
}
So it works fine at first time running it, but second time running it crashes at File.WriteAllBytes.
The service is not running, Windows clearly tells me it's used by my Installer Application when trying to delete it from Windows Explorer.
I'd really appreciate an beginner(which i am) friendly explanation why this happens the way i do it and in best case a solution. I found this post but this did not worked for me.
Thanks in advice.
PS: I know there are Setup Projects and more convenient/professional things, but thats not what i need/want
Well i am now installing it via cmd Process and sc create, still wonder why the InstallHelper wont release the file after installed successfully
I am trying to run a program on a Citrix VM located at \\site.local\shares\Agent_console\AC_Launch\AC_Launcher.exe /env=PROD
I am currently using the code below and it is stating the following
private void button13Chromatix_Launcher_Click(object sender, EventArgs e)
{
Process.Start(#"\\plumbedford.local\shares\Agent_Console\AC_Launch\AC_Launcher.exe",
"/Env=PROD");
}
But that fails with the following error:
Unable to access Agent Console XML network share. Try again?
This is a desktop shortcut that works using the same directory.
Thank you in advance.
Try using a literal string (with an # prefix), to ensure that backslashes are not misinterpreted.
It also looks like you have some typos in the location.
Try this:
Process.Start(#"\\site.local\shares\Agent_Console\AC_Launch\AC_Launcher.exe", "/env=PROD");
I currently developing a ASP.NET web application.
The application is designed for Google Chrome. I would like to pop out IE when printing is involved because Chrome lack preview etc. at a button click the IE should open. Here's the code:
protected void btn_print_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://localhost/storeapp/printpage.aspx?orderno=" + Request.QueryString["orderno"].ToString() + "");
}
Here I have passed a particular orderno to the URL. But when I click nothing happens. I have set IE as default web browser. Why is this?
There is no error shown? Any ideas?
What you are trying to do will only open an IE window on the SERVER not on the client machine. You cannot (for obvious security reasons) start a process on the clients machine.
You cannot force a client browser to open a link in a different browser.
You cannot force server to open process on Client side, what you have now is opening it on the Server side which is not desired behavior I believe.