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

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

博客园 - Martin XJ

windows2000 蓝色背景 楚留香mv2 楚留香mv cyberarticle Castle.Facilities.WebserviceIntegration SharpRush中的跨函数事务实现 - Martin XJ - 博客园 SharpRush中的AOP实现 自己的ORMapping starcraft2 Spring.net的一个小例子 EnterpriseLibrary 数据访问组件windows98不能使用 使用EnterpriseLibrary碰到的问题 好久都没写blog了 MS推荐的命名指南 Sybase DataWindow.net 1.5(Beta) For .Net 发布 IEWebcontrol webctrl_client目录配置 CodeSmith使用心得 mywallop、orkut、gmail的邀请 无法打开Web项目
Castle Windsor Wcf Facility的配置及调用IChannel的Close - Martin XJ
Martin XJ · 2009-01-11 · via 博客园 - Martin XJ

服务端windsor.xml:
<configuration>

  <facilities>

    <facility id="wcf"

                              type="Castle.Facilities.WcfIntegration.WcfFacility,

                                    Castle.Facilities.WcfIntegration" />

  </facilities>

  <components>

    <!--Services start-->

        <component

                 id="order service"

                 service="WCF.Contract.ServiceContract.IOrder, WCF.Contract"

                 type="WCF.Service.OrderService, WCF.Service" >

    </component>

    <!--Services end-->

  </components>

</configuration>服务端Global.asax

protected void Application_Start(object sender, EventArgs e)

        {

            Container = new WindsorContainer()

        .AddFacility<WcfFacility>()
        .Install(Configuration.FromXmlFile("Windsor.xml"));

        }

服务端 Svr文件:

<% @ServiceHost Service="order service"

       Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration" %>

<configuration>

  <facilities>

    <facility id="wcf"

                              type="Castle.Facilities.WcfIntegration.WcfFacility,

                                    Castle.Facilities.WcfIntegration" />

  </facilities>

       <components>

              <!--Services start-->

       <component

      id="order service"

       type="WCF.Contract.ServiceContract.IOrder, WCF.Contract"

       wcfEndpointConfiguration="order service"  lifestyle="transient">

    </component>

              <!--Services end-->

       </components>

</configuration>


这里为了每次都要启动一个实例,采用了transient的对象生命周期,
但是默认的WcfManagedChannelInterceptor不会自动调用IChannel.Close(),所以我改了下WcfManagedChannelInterceptor 的代码,添加了
Close方法:
#region IInterceptor Members
public void Intercept(IInvocation invocation)
  {
   EnsureOpenChannel(invocation);
   invocation.Proceed();
            Close(invocation);
  }

  #endregion

        void Close(IInvocation invocation)
        {
            if (lifestyle == LifestyleType.Transient)
            {
                IChannel channel = invocation.InvocationTarget as IChannel;
                if (channel != null)
                {
                    WcfUtils.ReleaseCommunicationObject(channel);
                }
            }
        }

这样的话每次调完一个wcf的实例,就把他关了