Example: How to Open URL from .Net from inside of Dexterity Code.

After Adding Library references. Use below code.
using System;
using System.Text;
using System.Diagnostics;
using System.Diagnostics.Process;


local ProcessStartInfo psi;
local text url;
local Process OpenUrl;


OpenUrl=new Process();
psi=new ProcessStartInfo();
url= "www.google.com";
psi.UseShellExecute = true;
psi.FileName= url;


OpenUrl.Start(psi);
Edit: To add error message and screenshot of stackoverflow.

2 comments:

  1. FYI - You don't need to make a new ProcessStartInfo, you can use the one that exists in the Process object. Here's the code I've used for years:

    Process process = new Process();
    process.StartInfo.Verb = "Open";
    process.StartInfo.FileName = url;
    process.StartInfo.CreateNoWindow = true;
    process.Start();

    ReplyDelete
  2. Hi John, Thanks for sharing your thoughts. I was actually not creating new ProcessStartInfo, but getting below error

    Unhandled object exception:
    Null Reference Exception

    EXCEPTION_CLASS_OBJECT_EXCEPTION
    ExceptionSubClass:0

    On googling it , someone on stackoverflow suggested below

    Since you specify that the exception is thrown on the proc.Start() , I would suggest you to declare a ProcessStartInfo, and use it with Process.Start()

    For example:

    Dim l As New ProcessStartInfo
    l.FileName = exepath
    ' ...
    Process.Start(l)


    I will try your suggested code. I am not very good with .Net :)

    ReplyDelete

Your Comments

.