我在服务器上使用ASP.NET 4.5,我有一个带有Web浏览器控件的.NET Windows应用程序,可以导航到服务器上的网页.
如果我在具有Internet Explorer 11的系统上运行Windows应用程序,我会收到一个脚本错误:"导航到另一个页面时,对象不支持属性或方法'attachEvent'".脚本文件是ScriptResource.axd,因此它不是我的任何脚本.
我知道Internet Explorer 11不再支持attachEvent(替换为attachEventListener?).然而,这在这里没有多大帮助,因为javascript是框架的一部分,而不是我的代码.
我在这里找到了框架的javascript源代码:http: //ajaxcontroltoolkit.codeplex.com/SourceControl/latest#Client/MicrosoftAjax/Extensions/Sys/WebForms/PageRequestManager.js
// DevDiv Bugs 100201: IE does not set referrer header on redirect if you set window.location, inject anchor node instead
// dynamic anchor technique only works on IE
if (Sys.Browser.agent === Sys.Browser.InternetExplorer) {
var anchor = document.createElement("a");
anchor.style.display = 'none';
// cancel bubble so body.onclick is not raised
anchor.attachEvent("onclick", cancelBubble);
// more code...
}
Run Code Online (Sandbox Code Playgroud)
根据我的理解,这是Sys.Webforms.PageRequestManager模块,它是核心ASP.NET框架的一部分.
执行attachEvent的行在Internet Explorer 11上出现脚本错误,但在旧版本的Internet Explorer上运行良好.
如何解决这个问题?有没有已知的解决方法?我无法对此进行任何更新.
我在使用TCP绑定的自托管应用程序中有一个WCF服务.如果我从应用程序启动一个外部进程"commandLineApp",即使在我的应用程序关闭后仍然继续,我下次在我的应用程序启动WCF服务时会遇到问题.
WCF说地址/端口已经在使用中.如果在重新启动应用程序之前关闭外部应用程序(根本没有使用WCF或任何套接字),WCF服务就可以正常启动.
看起来我的应用程序中的套接字句柄以某种方式由新进程"commandLineApp"继承,并且在该进程退出之前不会被释放.
如何阻止其他进程从我的主应用程序继承句柄(或成为子进程?)?目前我正在使用Process.Start启动其他进程,使用UseShellExecute设置为False,因为我需要设置EnvironmentVarables和RedirectStandardOutput/Error.
我认为如果我设置UseShellExecute = true,则会阻止子进程设置,但是我没有得到我需要的所有功能.
有没有解决这个问题的方法?请参阅下面的示例代码
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "commandLineApp.exe";
psi.Arguments = "/someParameter";
psi.EnvironmentVariables.Add("...", "...");
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.UseShellExecute = false;
Process process = new Process();
process.StartInfo = psi;
process.Start();
// Monitor if process with PID = process.Id is running
// ...
Run Code Online (Sandbox Code Playgroud)
编辑 - 附加信息:执行"netstat -noa"表示该端口与主应用程序的先前PID一起使用状态LISTEN,但不再有该PID的进程.一旦我关闭"commandLineApp",netstat命令就不再列出该端口了.
在主应用程序退出之前,WCF服务将像这样关闭:
try
{
serviceHost.Close(TimeSpan.FromSeconds(4));
}
catch (Exception)
{
serviceHost.Abort();
}
Run Code Online (Sandbox Code Playgroud)