2

I recently started to work with dynamic components, and it worked fine until I started with dynamic linked label. So here's my Problem: I want to open a website through a label link but every time I try to do that, it happens to break the program and give me the error: System.ComponentModel.Win32Exception.

 private void CreateDynamicLinkedLabel() { LinkLabel mylinklab = new LinkLabel(); mylinklab.Text = "asdasdasda"; mylinklab.AutoSize = true; mylinklab.LinkClicked += new LinkLabelLinkClickedEventHandler(mylinklab_Clicked); Controls.Add(mylinklab); } private void mylinklab_Clicked(object sender, LinkLabelLinkClickedEventArgs e) { Process.Start("http://www.google.com"); } 

I also tried this:

 private void mylinklab_Clicked(object sender, LinkLabelLinkClickedEventArgs e) { Process.Start("chrome.exe","http://www.google.com"); } 

i even included using System.Diagnostics; I tried to figure out why it wont work, but every Youtube Video looks like my code. Maybe there is another way to open a link, but i cant figure it out.enter image description here

2 Answers 2

1

I assume that you are targeting net core 3+. In this case you need to explicitly set UseShellExecute=true to get behaviour as it was in net framework. In net core there was a breaking changes in the default options for new process. More details https://github.com/dotnet/runtime/issues/17938

ProcessStartInfo psi = new ProcessStartInfo { FileName = url, UseShellExecute = true }; Process.Start (psi); 
Sign up to request clarification or add additional context in comments.

Comments

0

Add this in your method in your code:

Process.Start(new ProcessStartInfo() { FileName = url, UseShellExecute = true }); 

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.