惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
J
Java Code Geeks
D
DataBreaches.Net
B
Blog RSS Feed
D
Docker
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
Y
Y Combinator Blog
A
About on SuperTechFans
V
V2EX
罗磊的独立博客
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
月光博客
月光博客
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
阮一峰的网络日志
阮一峰的网络日志

博客园 - 阿修罗一平

IIS部署WCF出现的各种问题汇总 Infragistics控件的工具栏注册 NUnit的使用中可能遇到的问题 Linq备忘 Nihibernate的重要知识点 Devexpress使用记录 使用List数据集合,利用DevExpress.XtraReports开发Master-Detail报表 PDA访问WCF PDA(WinCE)项目开发中遇到的问题及解决方法总结 Grid控件绑定bindingSource后在新增行时设置Cell的初始值 “BindingSource绑定单个实体对象后在代码中赋值无效和无法显示”的解决方法 sqlservier2005转成sqlserver2000中出现的问题(WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) 项目考虑因素及解决方案(.net) 设计模式在工作中的应用(三) 设计模式在工作中的应用(二) 设计模式在工作中的应用(一) NHibernate示例 关于Remoting服务启动和停止的简单总结 将公司系统从SqlServer 2K移植到Oracle 10g中的简要总结
Remoting服务集成到IIS的简单总结
阿修罗一平 · 2007-08-27 · via 博客园 - 阿修罗一平

    因为项目的Remoting服务有可能集成到IIS中,所以下午利用一些时间,做了一个例子,实现了需要的功能,代码就凑合一下。
现在把这个过程总结一下:

1.       创建远程对象类Class1,它实现一个接口Interface1public class Class1 : MarshalByRefObject, Interface1
    {
        #region Interface1 Members
        public string SendMessage(string msg)
        {
            return "Hello " + msg;
        }
        #endregion
       public override object InitializeLifetimeService()
        {
            return null;
        }
    }

    public interface Interface1
   {
        string SendMessage(string msg);
    }

2.      建立虚拟目录



根据自己的需要选择选项,我是偷懒,不想受什么限制。生活中已经受到很多限制,难道在自己的机器上做开发还要收到限制吗?

F:\IISTest目录下建立Bin目录,然后将包含远程对象类的组件IISClassLibrary1.dll放入bin目录中。并创建Web.config

<system.runtime.remoting>
    <application>
      <service>
        <wellknownmode="Singleton"
                   type="IISClassLibrary1.Class1,IISClassLibrary1"
                   objectUri="Class1.soap"/>
      </service>
     <channels>
        <channel
           name="MyChannel"
           priority="100"
           ref="http"
            />
      </channels>
    </application>
 </system.runtime.remoting>

3.      建立客户端

使用配置文件,创建App.config配置文件

<?
xmlversion="1.0"encoding="utf-8" ?>
<configuration>
 <system.runtime.remoting>
    <application>
     <client>
       <wellknowntype="IISClassLibrary1.Class1,IISClassLibrary1"
                   url="http://localhost/IISTest/Class1.soap"/>

      </client>
    </application>
 </system.runtime.remoting>
</configuration>


            //客户端调用
            string
filename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            RemotingConfiguration.Configure(filename,false);

            IISClassLibrary1.Interface1 mgr = new IISClassLibrary1.Class1();           

            string retValue = mgr.SendMessage("yiping");

            获得所需要的结果:Hello yiping

    用“Hello yiping"给自己打气,努力做到“不抛弃,不放弃”,希望生活一天比一天美好。