C# 调用VS自带程序WebDev.WebServer40.EXE 源代码
通过Process.Start启动,VS自带程序WebDev.WebServer40.EXE
在内网架设网站时,为安装IIS条件下用VS自带的小程序来测试效果非常不错!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace WebServer
{
public partial class FormApp : Form
{
public FormApp()
{
InitializeComponent();
} private void btnStart_Click(object sender, EventArgs e)
{
string _AppRoot = this.txtAppRoot.Text;
string _Port = this.txtPort.Text;
string _WebPath = this.txtWebPath.Text;
string _WebvPath = this.txtWebvPath.Text;
try
{
//简单校验
CheckBoolTxt(_AppRoot, _Port, _WebPath, _WebvPath);
string arguments = string.Format("/port:{0} /path:{1} /vpath:{2}", _Port, _WebPath, _WebvPath);
System.Diagnostics.Process.Start(_AppRoot, arguments);
this.linkLabel1.Text = string.Format("http://localhost:{0}{1}", _Port, _WebvPath);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示:");
}
} private void CheckBoolTxt(string _AppRoot, string _Port, string _WebPath, string _WebvPath)
{
if (!System.IO.File.Exists(_AppRoot))
{
throw new Exception("找不到指定程序!");
}
if (!System.Text.RegularExpressions.Regex.IsMatch(_Port, @"^(([1-6][0-5][0-5][0-3][0-5])|([1-9][0-9][0-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9])|([1-9]))$")) //^[1-6]?[\d]{0,4}$
{
throw new Exception("端口:1-65535之间未使用的端口号!");
}
if (!System.IO.Directory.Exists(_WebPath))
{
throw new Exception("物理路径不存在,请指定有效的目录!");
}
if (!_WebvPath.Contains("/"))
{
throw new Exception("虚拟目录必须以'/'开头!");
}
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();
int counts = ipEndPoints.Count<IPEndPoint>(o => o.Port == int.Parse(_Port));
if (counts > )
{
throw new Exception("端口已被占用!");
}
} private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(this.linkLabel1.Text);
}
}
}


C# 调用VS自带程序WebDev.WebServer40.EXE 源代码的更多相关文章
- vs2010旗舰版后,运行调试一个项目时调试不了,提示的是:无法使用“pc”附加到应用程序“webdev.webserver40.exe(PID:2260”
具体问题描述: vs2010旗舰版后,运行调试一个项目时调试不了,能编译,按ctrl+f5 可以运行,但是就是调试就不行,提示的是:无法使用“pc”附加到应用程序“webdev.webserver40 ...
- 开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误
已经解决,问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open() ...
- ASP.NET程序运行出现WebDev.WebServer40.exe已停止工作解决方法(netsh winsock reset)
问题描述:在开发系统时候运行程序突然报出"WebDev.WebServer40.exe已停止工作"的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.O ...
- 在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误的解决办法
问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open()处. 但是 ...
- WebDev.WebServer40.EXE
http://www.cnblogs.com/tong-tong/archive/2013/05/02/3049428.html 大学玩asp.net时就发现VS在Debug时会起一个web服务,这东 ...
- WebDev.WebServer40.EXE命令使用
"C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\WebDev.WebServer40.EXE&quo ...
- 用WebDev.WebServer40.EXE调试VS代码
1.找到WebDev.WebServer40的录井,一般位于C:/Program Files (x86)/Common Files/Microsoft Shared/DevServer/10.0/We ...
- WebDev.WebServer40.exe已停止工作
今天写程序的遇到这个错误 错误的原因是代码中有死循环
- VS WebDev.WebServer40
vs2010下有一个WebDev.WebServer40工具,可以直接拿来当服务器用,这样就不用再安装iis了.位置在 C:\Program Files (x86)\Common Files\micr ...
随机推荐
- 喜闻乐见的const int *p、int* const p、const int* const p
不废话直接代码示例: void f(const int *p) { ; *p = ; // error p = &b; // fine } void f(int* const p) { ; * ...
- CronTrigger中cron表达式使用
1.定时任务,当执行是具体时间的时候,不会立即执行,而是到指定时间执行. 2.实现Job接口时候,类中要有无参的public构造方法. 3.表达式中共用七个字段,按顺序是秒.分.时.日.月.周.年,默 ...
- openWRT自学---针对backfire版本的主要目录和文件的作用的分析整理
特别说明:要编译backfire版本,一定要通过svn下载:svn co svn://svn.openwrt.org/openwrt/branches/backfire,而不能使用http://dow ...
- CDH配置JAVA_HOME
jdk成功安装 java -version 正确显示版本 echo $JAVA_HOME 正确输出路径 但CDH链接数据库还是报错: Error: JAVA_HOME is not set and ...
- MacOS 自带文件编码格式转换工具
[命令功能]iconv 是Linux操作系统用于将文本编码格式从一种转外另外一种的工具命令.[使用方法] iconv [OPTION...] [-f ENCODING] [-t ENCODING] [ ...
- JavaScript 是脚本语言
JavaScript 是一种轻量级的编程语言. JavaScript 是可插入 HTML 页面的编程代码. JavaScript 插入 HTML 页面后,可由所有的现代浏览器执行. JavaScrip ...
- yii 国际化
http://www.yiichina.com/doc/guide/2.0/tutorial-i18n config/main.php 外层加 'language' => 'en-US', 's ...
- [ACM] hdu 3923 Invoker (Poyla计数,高速幂运算,扩展欧几里得或费马小定理)
Invoker Problem Description On of Vance's favourite hero is Invoker, Kael. As many people knows Kael ...
- (三)Solrj4到Solrj5的升级之路
(三)Solrj4到Solrj5的升级之路 Solr5发布了,带来了许多激动人心的新特性,但Solrj的许多接口也发生了变化,升级是痛苦的,但也是必须的,下面就赶紧来看看有哪些代码需要升级吧. 变化1 ...
- 微信小程序网络请求的setDate
我感觉这个无比的奇葩..... 因为之前react的时候,我习惯在请求成功的时候直接this.setDate.........但是,在微信小程序中,一定要将this换成一个变量...一定要!!!否则会 ...