好的,我们都知道如何使用PING来测试与IP地址的连接.我需要做的是类似的事情,但测试我对给定IP地址的出站请求以及特定端口(在本例中为1775)是否成功.应该最好从命令提示符执行测试.
我正在尝试使用我的应用程序分发IIS Express.IIS Express将在端口80上提供外部Web请求.
我在运行IIS Express以及提供外部请求方面没有任何问题,但Microsoft以其无限的智慧决定从控制台窗口以及系统托盘项运行IIS Express.您可以通过命令行参数禁用托盘项目,但不能通过控制台窗口禁用托盘项目.
我想在没有显示控制台窗口的情况下运行IIS Express.我还想从Windows服务运行IIS Express.
从我的应用程序中运行以下代码正是我想要的:
Directory.SetCurrentDirectory(string.Format("{0}\\IIS Express", iisProgramDirectory));
process.EnableRaisingEvents = true;
//process.Exited += new EventHandler(process_Exited);
process.StartInfo.FileName = "iisexpress.exe";
process.StartInfo.Arguments = string.Format("\"/config:{0}webservice\\config\\applicationhost.config\"", dataDirectory);
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
//process.StartInfo.UserName = "Administrator";
//System.Security.SecureString securePwd = new System.Security.SecureString();
//string password = "**********";
//char[] pword = password.ToCharArray();
//for (int i = 0; i < pword.Length; i++)
//{
// securePwd.AppendChar(pword[i]);
//}
//process.StartInfo.Password = securePwd;
process.Start();
Run Code Online (Sandbox Code Playgroud)
显然我是以管理员身份运行的.IIS Express显然需要以管理员权限运行才能提供外部请求以及侦听端口80.
我的Windows服务在Windows服务帐户下运行,我认为该帐户具有完全权限,但当我尝试从Windows服务运行时,IIS Express进程正好退出,错误代码为0.
我尝试了很多场景(正如你可以从代码片段中看到的那样),但似乎无法使用我的Windows服务运行IIS …
FileInfo fi = new FileInfo(fileToExcecute);
Directory.SetCurrentDirectory(fi.DirectoryName);
ProcessStartInfo pInfo = new ProcessStartInfo();
pInfo.FileName = fileToExcecute;
pInfo.RedirectStandardOutput = false;
pInfo.RedirectStandardError = false;
pInfo.CreateNoWindow = false;
pInfo.UseShellExecute = true;
pInfo.WorkingDirectory = fi.DirectoryName;
if (runas)
pInfo.Verb = "runas";
pInfo.WindowStyle = ProcessWindowStyle.Normal;
Process p = Process.Start(pInfo);
Run Code Online (Sandbox Code Playgroud)
任务栏中缺少应用程序图标.这只是一个空白的广场!
上面的代码适用于多个项目但是使用一个特定程序失败 - 我们称之为projectX.exe.我重新编写了projectX.exe的Main和启动方法,以便它们模仿另一个显示其图标的项目.
我已经试了好几天才发现原因,但却失败了.我尝试了各种想法,包括更改图标,在运行时更改它,以及切换是否应该显示.
如果我要求以管理员身份运行projectX.exe,则图标显示正常,但我的客户端无法使用该选项.
编辑2017年10月20日 如果我将'projectX.exe'的名称更改为其他名称,例如'test.exe',则图标会在任务栏中显示OK.存储在注册表中的程序的图标在哪里?
编辑2017 年10月22日按照建议刷新图标后,从文件资源管理器运行程序或创建快捷方式时,任务栏中不再显示该图标.
编辑2017年11月12日 运行程序"以管理员身份",图标将按预期显示在任务栏中.
当您点击API v2中的PayPal按钮时,浏览器的工具栏等也会变灰并且无法访问。PayPal流程完成后将重新启用它。这些操作与将其应用于整个浏览器一样,就像是一个模式弹出窗口一样。
大概这是内置在PayPal API中的功能,但我认为这是不可能的,但显然是可行的。
有人知道执行此操作的脚本吗?
无法加载“文件引用”:ID 为“guid”的域对象已在此或其他域模型中定义。
要加载的文件是 DevExpress xpo 数据模型文件,并且该文件本身至少已成功加载 3 次。
我在整个硬盘上搜索了ID guid,没有任何结果。
我怎样才能解决这个问题?
所以我目前在我的解决方案中添加了2个WSDL作为服务引用.它们在我的app.config文件中看起来像这样(我删除了"bindings"字段,因为它不感兴趣):
<system.serviceModel>
<client>
<endpoint address="http://localhost:8080/query-service/jse" binding="basicHttpBinding" bindingConfiguration="QueryBinding" contract="QueryService.Query" name="QueryPort" />
<endpoint address="http://localhost:8080/dataimport-service/jse" binding="basicHttpBinding" bindingConfiguration="DataImportBinding" contract="DataService.DataImport" name="DataImportPort" />
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
当我使用WSDL时,它看起来像这样:
using (DataService.DataClient dClient = new DataService.DataClient())
{
DataService.importTask impt = new DataService.importTask();
impt.String_1 = "someData";
DataService.importResponse imptr = dClient.importTask(impt);
}
Run Code Online (Sandbox Code Playgroud)
在"using"语句中,在实例化DataClient对象时,我有5个构造函数可供我使用.在这种情况下,我使用默认构造函数:
new DataService.DataClient()
Run Code Online (Sandbox Code Playgroud)
它使用内置的端点地址字符串,我假设它是从app.config中提取的.但我希望应用程序的用户可以选择更改此值.
1)以编程方式获取此字符串的最佳/最简单方法是什么?
2)然后,一旦我允许用户编辑和测试值,我应该在哪里存储它?
我希望将它存储在一个地方(如app.config或等效的),这样就不需要检查值是否存在以及我是否应该使用备用构造函数.(为了保持我的密码,你知道吗?)
有任何想法吗?建议?
编辑
也许我应该问一下这些替代构造函数.
例如,其中一个看起来像这样:
new DataService.DataClient(string endPointConfigurationName,
string remoteAddress)
Run Code Online (Sandbox Code Playgroud)
可以为"endPointConfigurationName"和"remoteAddress"传递什么值?
EDIT2
在这里回答我自己的问题,"endPointConfigurationName"看起来与app.config XML中的"name"相同,"remoteAddress"的格式与app.config XML中的"endpoint address"相同.
也!关于获取EndPointAddresses的第一个问题的答案如下:
ClientSection clSection =
ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection;
ChannelEndpointElementCollection endpointCollection =
clSection.ElementInformation.Properties[string.Empty].Value as ChannelEndpointElementCollection;
Dictionary<string, string> nameAddressDictionary =
new …Run Code Online (Sandbox Code Playgroud) 从LAN上的另一台计算机向TcpListener服务发送消息时,您需要知道服务器的IP地址和端口.该端口很可能已经知道,因为您可能已经选择了该端口,但如果IP地址可能不同,您是否可以通过某种方式发现IP地址.
在我看来,您需要通过另一种方法将此信息提供给发件人.
c# ×2
app-config ×1
asp.net ×1
devexpress ×1
iis-express ×1
installaware ×1
ip ×1
javascript ×1
paypal ×1
sockets ×1
tcplistener ×1
wcf ×1
web-services ×1
windows ×1
winforms ×1
wsdl ×1
xpo ×1