注册你的数据库访问类到服务器上
客户端可以远程访问到该类
然后就可以直接操作服务器了
采用tcp/ip协议
客户端可以远程访问到该类
然后就可以直接操作服务器了
采用tcp/ip协议
解决方案 »
- C#BHO用webBrowser还是ihtmldocument2对网页非法字符屏蔽
- TcpClient连接问题!!!
- 1年多没写代码了,现在连MSDN也看不懂了?求几行代码(几个BYTE异或)
- datagridview 数据绑定显示
- SQL高高手请进,呵呵
- c#设计表单时候,我关闭了一下,然后居然不知道打开哪个文件来打开表单设计界面了?
- Word.Document.open()为什么参数在不同的版本下变化?
- 急,c#读取excel有下拉框的cell值的问题,顶者皆有分
- 各位大虾能不能介几本C#的好书
- 为什么我用DrawReversibleLine方法画的线,总有虚点不能擦除
- 水晶报表需要注册那些组件。
- 急!!!,有关c# 中调用API函数的问题(msn:franklitian6@hotmail)[分不够在发贴!!]
是的!可以给我参考下吗?
using system.runtime.remoting;
using system.runtime.remoting.channels.tcp;namespace remotingsamples {
public class helloserver : ihello { public static int main(string [] args) { tcpchannel chan = new tcpchannel(8085);
channelservices.registerchannel(chan);
remotingservices.registerwellknowntype(
"server", "remotingsamples.helloserver", "sayhello", wellknownobjectmode.singlecall);
system.console.writeline("请按 键退出...");
system.console.readline();
return 0;
} public helloserver()
{
console.writeline("helloserver 已激活");
} ~helloserver()
{
console.writeline("对象已清除");
} public forwardme hellomethod(forwardme obj)
{
console.writeline("hello.hellomethod : {0}", name);
return "hi there " name;
}
}
}
using system.runtime.remoting;
using system.runtime.remoting.channels.tcp;namespace remotingsamples {
public class client
{
public static int main(string [] args)
{
tcpchannel chan = new tcpchannel();
channelservices.registerchannel(chan);
forwardme param = new forwardme();
helloserver obj = (helloserver)activator.getobject(
typeof(remotingsamples.helloserver), "tcp://localhost:8085/sayhello");
if (obj == null) system.console.writeline("无法定位服务器");
else {
console.writeline("值为 " param.getvalue());
forwardme after = obj.hellomethod(param);
console.writeline("呼叫后的值为 " after.getvalue());
}
return 0;
}
}
}
下面是 makefile:all: server.exe client.exe share.dllshare.dll: share.cs
csc /debug /target:library /out:share.dll share.csserver.exe: server.cs
csc /debug /r:share.dll /r:system.runtime.remoting.dll server.csclient.exe: client.cs server.exe
csc /debug /r:share.dll /r:server.exe /r:system.runtime.remoting.dll client.csclean:
@del server.exe client.exe *.pdb *~ *.*~
你的代码不全吧?还有share.cs呢?