如何实现客户端运行服务器端的应用程序

losa 2011-04-19 09:04:32
想要在客户端通过浏览器直接打开运行服务器端的应用程序,用什么技术比较好,应该如何实现
...全文
477 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
子夜__ 2011-05-03
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 tjbdsh 的回复:]

引用 4 楼 wxr0323 的回复:
System.Diagnostics.Process

引用哪个名称空间?
[/Quote]

鼠标点击上 上档键+alt+F10

自动显示。。
jarod0407 2011-05-03
  • 打赏
  • 举报
回复
可以用netremoting 来做,先创建一个消息的类

using System;
using System.Collections.Generic;
using System.Text;

namespace HelloMesage
{
public class Hello : System.MarshalByRefObject
{
public Hello()
{
Console.WriteLine("Constructor called");
}

~Hello()
{
Console.WriteLine("Deconstructor called");
}

//供客户端调用的方法
public string Greeting(string name)
{
Console.WriteLine("Greeting called");

return "Hello " + name;
}
}
}

服务器端的程序

using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;

namespace ServerConsoleApp
{
class Program
{
static void Main(string[] args)
{
TcpServerChannel channel = new TcpServerChannel(8086);//提供服务的端口
ChannelServices.RegisterChannel(channel, false);

//参数(消息的类,服务器的名称,调用的模式)
RemotingConfiguration.RegisterWellKnownServiceType(typeof(HelloMesage.Hello), "hi", WellKnownObjectMode.SingleCall);
Console.WriteLine("Press any key to exit");
Console.ReadLine();

}
}
}

客户端

using System;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Collections.Generic;
using System.Text;

namespace ClientConsoleApp
{
class Program
{
static void Main(string[] args)
{

TcpClientChannel channel = new TcpClientChannel();

ChannelServices.RegisterChannel(channel, false);

HelloMesage.Hello obj = (HelloMesage.Hello)Activator.GetObject(typeof(HelloMesage.Hello), "tcp://localhost:8086/hi");
if (obj == null)
{
Console.WriteLine("could not locate server");
}
else
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine(obj.Greeting("Christian is " + i.ToString()));//调用服务器的方法
}
}
}

}
}

客户端和服务器端都应该引用HelloMessage这个消息类。
losa 2011-05-03
  • 打赏
  • 举报
回复
System.Diagnostics.Process只能在服务器上打开,一旦发布后,客户端就没有反映了
还有其他解决方案吗
losa 2011-04-29
  • 打赏
  • 举报
回复
高手去哪里了
losa 2011-04-22
  • 打赏
  • 举报
回复
请高手们帮帮忙?
我就想要在客户端打开服务器的运行程序,并且是在客户端运行的,直接在浏览器中运行就可以了
haa17 2011-04-19
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/zh-cn/library/system.diagnostics.process(v=vs.80).aspx[Quote=引用 5 楼 tjbdsh 的回复:]

引用 4 楼 wxr0323 的回复:
System.Diagnostics.Process

引用哪个名称空间?
[/Quote]
tjbdsh 2011-04-19
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wxr0323 的回复:]
System.Diagnostics.Process
[/Quote]
引用哪个名称空间?
子夜__ 2011-04-19
  • 打赏
  • 举报
回复
System.Diagnostics.Process
losa 2011-04-19
  • 打赏
  • 举报
回复
也就是说如果我在客户端点击浏览器中的按钮,我就能直接在客户端运行服务器上的某个应用程序,这个应用程序是自己开发的
罗纳尔迪尼奥 2011-04-19
  • 打赏
  • 举报
回复
不是很明白?
losa 2011-04-19
  • 打赏
  • 举报
回复
补充一点,是运行在客户端的,不是在服务器上运行

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧