Custom Compiled Cassini from Visual Studio

Friday, 17 April 2009 08:13 AM
by Coose

In my previous post, I described compiling a custom version of Cassini that could listen to external requests, not just loopback.  Now, I want to use that version of Cassini to debug from Visual Studio.  The problem is that the command lines are different.  Visual Studio uses Webdev.WebServer.exe, and issues argument in the format

/port:1234 /path:c:\temp /vpath:/test

Cassini expects arguments in the format

apppath port virtroot

So, in main.cs, I have modified the Main function as so:

   50 public MainForm(String[] args) {

   51     //_portString = "80";

   52     //_virtRoot = "/";

   53     //_appPath = string.Empty;

   54 

   55     // look for arguments in the form of /port:1234, or /path:"abcdefg" or /vpath:/

   56     foreach (string arg in args)

   57     {

   58         if (arg.StartsWith("/port:", StringComparison.OrdinalIgnoreCase)) _portString = arg.Substring(6).Trim();

   59         if (arg.StartsWith("/path:", StringComparison.OrdinalIgnoreCase)) _appPath = arg.Substring(6).Trim();

   60         if (arg.StartsWith("/vpath:", StringComparison.OrdinalIgnoreCase)) _virtRoot = arg.Substring(7).Trim();

   61     }

   62 

   63     try {

   64         if (string.IsNullOrEmpty(_appPath) && args.Length >= 1) _appPath = args[0];

   65         if (string.IsNullOrEmpty(_portString) && args.Length >= 2) _portString = args[1];

   66         if (string.IsNullOrEmpty(_virtRoot) && args.Length >= 3) _virtRoot = args[2];

   67     }

   68     catch {

   69     }

   70 

   71     InitializeForm();

   72 

   73     if (string.IsNullOrEmpty(_appPath)) {

   74         appDirTextBox.Focus();

   75         return;

   76     }

   77 

   78     Start();

   79 }

Now, the application will accept command line arguments in either form.

I copy this cassini-v35.exe to C:\Program Files\Common Files\microsoft shared\DevServer\9.0 and rename it webdev.webserver.exe (making a backup of the old webdev.webserver.exe of course), and now I can launch my custom Cassini from Visual Studio.

Comment on this
Development
| |

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading