IIS/WAS托管:在AppInitialize中连接所有内容..可以吗? [英] IIS/WAS hosting : wiring up everything in AppInitialize .. is it possible ?

查看:65
本文介绍了IIS/WAS托管:在AppInitialize中连接所有内容..可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用0 config在WAS上设置net.tcp,也就是说,我想以编程方式设置所有内容(例如在Windows服务中).

i'm trying to setup net.tcp on WAS with 0 config, that is, i want to setup everything programmatically (as in a windows service).

我尝试将这段代码放入AppInitialize方法中

ServiceHost
hostSystem =     
          hostSystem.AddServiceEndpoint( 类型 (WKI.Cosmo.Interop. IClientServices              );
hostSystem.Open();

I've tried to put this code in the AppInitialize method 

ServiceHost
hostSystem = newServiceHost(typeof(WKI.Cosmo.Business.ClientServices));    
BindingtcpBinding = newNetTcpBinding(SecurityMode.None, true);          hostSystem.AddServiceEndpoint(typeof(WKI.Cosmo.Interop.IClientServices), tcpBinding,           "IClientServices2.svc");
hostSystem.Open();

此代码已调用,但出现以下错误.
System.InvalidOperationException:找不到与绑定NetTcpBinding的终结点计算机匹配方案net.tcp的基地址.注册的基址方案为[].

this code is called but gives the following error.
System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [].

这在某种程度上是有意义的,但是由于我托管在IIS/WAS中,因此我当然不希望注册基址.似乎这种方法被称为早期.
我正在尝试做一种受支持的方法吗?有什么解决办法吗?

This makes somehow sense, however of course i do not wabnt to register a base address since i'm hosted in IIS/WAS. Seems like this method is called to early.
Is what i'm trying to do a supported way ? Is there any solution ?

谢谢

恩里科·萨巴丁

推荐答案

使用ServiceHostFactory,您可以控制服务实例的设置(我也将其用于singelton)以及其他不错的东西.

using ServiceHostFactory u can control the service instance to setup (i use it for a singelton as well), and other nice stuff.

但是,如何在web.config中完全没有信息,仍然有IIS/WCF登陆我的工厂?

But how can i have no info in the web.config at all, still have IIS/WCF landing on my factory ?

我认为我需要在调用链中挂接某个东西,然后才能执行此操作. Appinitialize似乎是一个不错的地方,但是,从错误中我得到了我不知道如何获取基址(net.tcp://myserver/myvdir)的信息,并且我也不想对其进行硬编码.

I think i need to hook something before in the call chain to do that. Appinitialize seems a nice place, however , from the error i get i don't kow how to grab the baseaddress (net.tcp://myserver/myvdir)., and i don't want to hardocode it.

我希望我现在能清楚地解释自己:)

I hope i explained myself clearly now :)


这篇关于IIS/WAS托管:在AppInitialize中连接所有内容..可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆