问题标签 [servicehost]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
546 浏览

c# - 从另一个 Servicehost C# 访问 WCF 中的 ServiceHost

我有 2 个合同托管在两个服务主机中我需要在第一个合同中有一个单例对象,因此当另一个服务主机尝试从该类创建一个对象时,它只会从第一个服务主机检索相同的对象,

这可能意味着我需要找到访问服务主机并从中获取对象而不是创建一个新的对象.. 有什么想法吗?

提前致谢

0 投票
2 回答
2686 浏览

c# - WCF 监听基地址 anyip

我希望我的服务主机拥有任何 IP 的基地址,所以我尝试了这个

它给了我无效的URI格式

有谁知道我应该怎么写这个?

好吧,我尝试从本地局域网外部访问它,但它不起作用,我使用 tcpiplistener 制作了一个小型测试软件,我开始监听相同的端口,并将 tcpip 协议的基地址设置为 anyip 和小型测试软件工作了,所以我发现我需要做的就是为 Web 服务设置相同的值 -</p>

这也意味着我的系统管理员完成了确保端口/服务器可以从外部访问的工作,现在我的网络服务不应该工作!?它可以工作,但我无法从外部访问它,如果我在同一台 PC 上运行客户端,我可以从同一台 PC 访问它

0 投票
1 回答
274 浏览

.net - 服务主机效率

希望你能帮助我请..

我在我的程序中使用 WCF。其中一部分包括在使用 netNamedTypeBinding 的自助服务类型方案中使用 ServiceHost。当我在我的类中包含 ServiceHost 然后实例化该类时(此时 ServiceHost 设置为 null),内存使用量增加了大约 9Mb。如果我注释掉 ServiceHost 属性,内存不会跳转。

这是 ServiceHost 使用的相当古老的内存块。有没有办法减少这种情况,或者是否有更精简的 ServiceHost 版本?出于绝望,我真的需要我的程序尽可能提高内存效率。

非常感谢您的时间

0 投票
1 回答
5812 浏览

wcf - 使用 ServiceHostFactory 时出现“安全支持提供程序接口 (SSPI) 协商失败”

我最近开始使用自定义 ServiceHostFactory,因为我想在 WCF 中使用依赖注入。我的客户端和服务都在我的本地计算机上从 VS2010 运行,并且该服务正在使用 ASP.NET 开发服务器。为什么我现在有这个问题?过去,我在 wsHttpSecurity 上取得了成功,在我的本地计算机上同时拥有客户端和服务。我真的认为这里唯一的区别是使用了 ServiceHostFactory。我试过使用 userPrincipalName 属性,但我什至不确定我应该为这个值输入什么。应该是机器名\用户名吗?这个属性会有所不同吗?我会非常感谢您提供的任何帮助。

0 投票
1 回答
584 浏览

wcf - Endpoint添加到服务主机后可以修改吗?

我试图弄清楚如何获取服务主机端点的句柄并修改它们的身份。我在配置文件中定义了端点,但想根据环境以编程方式修改端点(例如:QA、UAT、Prod)

服务托管在 IIS6 上,我正在使用 servicehostfactory 向 IIS 提供我的扩展服务主机类。

我正在使用打开事件来获取已从配置文件中定义但无法弄清楚如何修改其身份的端点的句柄。这甚至可能吗?端点在创建后是不可变的吗?

如果我无法修改端点,那么 servicehost 的“Opening”事件是否是添加服务端点的正确事件?

0 投票
1 回答
856 浏览

asp.net-mvc - 在 MVC 中提供 WCF 服务

我想知道是否可以通过 MVC 为 WCF 服务提供服务。我看过一些与 RESTful 服务相关的帖子,但我并不打算创建 RESTful 服务。

就从 MVC 提供 .svc 文件而言,我也看到过这个主题,但我也不是在寻找那个。

基本上,我只是想通过 MVC 公开我的 WCF 服务,而不是带有 svc 文件的典型 Wep App 类型结构。

因此,我不会使用 ttp://localhost/MyService.svc,而只需使用 ttp://localhost/MyService,然后它会转到返回数据的控制器。

是否有可能有一个“服务主机”控制器?我认为最大的障碍是 IIS 基于 .svc 扩展名以某种方式处理服务 - 是否必须为此设置某种自定义处理程序?

有什么想法吗?

0 投票
4 回答
5214 浏览

wcf - WCF slow ServiceHost.Open() call

This is a similar question as this one: Win32Exception @ ServiceHost.Open() for WCF service.

I have a machine that is very slow on the ServiceHost.Open call below. It consistently takes 7 seconds or so to open the service, every time. This machine is my home box, and it is not part of a domain.

I can run the same code on another box (my work box) which is part of a domain and the service host opens in about 3-4 seconds on the first call, but if I run the program again the service host opens in about 1 second or less.

I have worked with MS support on this, and we generated trace logs and the part it's hanging in is where is goes out and tries to connect to a domain, even on the machine that isn't part of a domain. And it gets the "The specified domain either does not exist or could not be contacted." exception in the trace log, and that's where all the time is getting eaten up.

But what's really weird is that even on my work machine, if I'm not connected to a domain (like if I'm not on my work network and just running from home) I still don't get the delay.

I rebuilt my machine using Windows 7 64-bit, and the same behavior occurs (was running XP SP3, which I restored when Windows 7 didn't seem to fix the problem).

I just wondered if anyone had any ideas of what could cause this. By the way, if I disable "Client for microsoft networks", the time is like 4 seconds to open the ServiceHost, but that's still not as fast as this machine used to be able to open the service. Somehow, it thinks it's supposed to be part of a domain or something.

Here is my app.config, but I don't have any special security configuration settings for the service in there, only some diagnostic settings to enable the WCF trace.

Note also that my service definition has SessionMode required (see below). If I take the SessionMode requirement out, I don't get the delays.

0 投票
1 回答
1265 浏览

wcf - 自托管 NetTcp 服务超时错误

我有一个包含 WCF NetTcp 主机的 Windows 服务。从客户端开始,当我开始通过 tcp 调用服务时,它们一开始运行良好,但几分钟后它们都开始出现可怕的 WCF 超时错误,这实际上与超时无关:

发送到 net.tcp://myserver:8080/ListingService 的此请求操作在配置的超时 (00:01:00) 内未收到回复。

我从该站点上的其他帖子中看到,很多时候这与最大消息大小有关,但我已经将这些设置为无济于事。

这是我的 Windows 服务代码:

这是客户端配置,以防有任何不同:

我确保关闭我的客户端连接,这是代码:

0 投票
1 回答
2689 浏览

c# - WCF:如何阻止 myServiceHost.Close() 处理 myServiceHost 对象?

显然 Close 和 Dispose 实际上是相同的。我希望能够关闭和打开我的 ServiceHost 实例,而不必每次都重新实例化它。有任何想法吗?谢谢。

0 投票
19 回答
100813 浏览

wcf - wcf 服务中 ServiceHost 指令中的服务类型问题

我正在开发一个简单的 wcf 服务进行测试。当我使用本地 IIS 7.5 测试此服务时,它可以正常工作。但是当我在 web IIS 中托管它时,我收到了这个错误:

找不到类型“WcfServiceLibrary1.Service1”,作为 ServiceHost 指令中的服务属性值提供,或在配置元素 system.serviceModel/serviceHostingEnvironment/serviceActivations 中提供。

我的 ServiceHost 是:

请帮我解决这个问题