远程处理IIS下托管的对象 [英] Remoting objects hosted under IIS
问题描述
我已经按如下所示构建了该应用程序.但是我收到错误消息,因为远程服务器返回错误:(404)未找到".任何人都可以告诉您如何更正该错误.请帮帮我.
构建一个简单的远程对象
Hello.cs(类库)
I have built the application as follows. But i''am getting an error as "The remote server returned an error: (404) Not Found". Can anyone tell how to correct that error. Please help me out.
Build a Simple Remote Object
Hello.cs(Class library)
using System;
using System.Runtime.Remoting;
namespace HelloWorldObject
{
public class Hello : MarshalByRefObject
{
public string HelloWorld(string str)
{
return "Hello World received " + str + " from the client";
}
}
}
添加对以下内容的引用:
1)System.Runtime.Remoting
在Microsoft Internet信息服务中托管远程对象
1)创建一个名为HelloWorldWeb的新目录(最好在\ Inetpub \ wwwroot \下).
2)在HelloWorldWeb目录下创建一个名为bin的目录.
3)将HelloWorldObject.dll文件从HelloWorldObject \ bin \ debug \目录复制到HelloWorldWeb \ bin \目录.
4)使用Notepad.exe创建一个名为Web.config的新文件.复制以下文本,然后将其保存在HelloWorldWeb目录中:web.config
Add references to the following:
1) System.Runtime.Remoting
Host the Remote Object in Microsoft Internet Information Services
1) Create a new directory called HelloWorldWeb (preferably under \Inetpub\wwwroot\).
2) Create a directory named bin beneath the HelloWorldWeb directory.
3) Copy the HelloWorldObject.dll file from the HelloWorldObject\bin\debug\ directory to the HelloWorldWeb\bin\ directory.
4) Use Notepad.exe to create a new file called Web.config. Copy the following text, and then save it in the HelloWorldWeb directory: web.config
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall">
type="HelloWorldObject.Hello, HelloWorldObject"
objectUri="SimpleHelloWorld.soap" />
</wellknown></service>
</application>
</system.runtime.remoting>
</configuration>
5)单击开始",指向程序",然后单击管理工具".打开Internet服务管理器.
6)在IIS中创建一个虚拟目录.
7)使虚拟目录别名为SimpleHello,然后将源目录设置为HelloWorldWeb目录.
构建一个简单的控制台应用程序以测试远程对象
TestClient.cs(控制台应用程序)
5) Click Start, point to Programs, and then click Administrative Tools. Open Internet Services Manager.
6) Create a virtual directory in IIS.
7) Make the virtual directory alias SimpleHello, and then set the source directory to the HelloWorldWeb directory.
Build a Simple Console Application to Test the Remote Object
TestClient.cs(Console application)
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Services;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using HelloWorldObject;
namespace Client
{
class TestClient
{
[STAThread]
static void Main(string[] args)
{
HttpChannel http = new HttpChannel();
ChannelServices.RegisterChannel(http);
Hello obj = (Hello)Activator.GetObject(typeof(Hello),"http://localhost/SimpleHello/SimpleHelloWorld.soap");
Console.WriteLine(obj.HelloWorld("CLIENT APPLICATION"));
}
}
}
添加对以下内容的引用:
1)System.Runtime.Remoting
2)HelloWorldObject.dll(通过浏览到.dll文件的位置)
Add references to the following:
1) System.Runtime.Remoting
2) HelloWorldObject.dll (by browsing to the location of the .dll file)
推荐答案
请您参阅本文和文档
IIS下的NET远程处理-作为客户端的ASP.NET应用程序
could you please see this articles and documents
NET Remoting under IIS - ASP.NET Application as Client
这篇关于远程处理IIS下托管的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!