【问题标题】:"object reference not set to an instance of an object" when adding a WCF service reference添加 WCF 服务引用时“对象引用未设置为对象的实例”
【发布时间】:2013-06-17 20:06:32
【问题描述】:

我创建了一个 WCF 服务来管理跟踪事件,例如:

[ServiceContract]
public interface IEvents
{
    [OperationContract]
    List<BOEvent> GetEvents(int numResults = 100);


    [OperationContract(IsOneWay=true)]
    void AddEvent(BOEvent);
}

我在 VS2010 中编译它并添加了“服务参考”,但出现以下错误:

我的服务运行良好,我可以在浏览器中看到它及其 wsdl。

怎么了?

【问题讨论】:

  • 我猜这是因为使用了可选参数int numResults=100

标签: c# asp.net wcf


【解决方案1】:

AddEvent 参数 BOEvent 不应该也有名称而不仅仅是类型吗?这还能编译吗?

【讨论】:

  • 是的,这是一个错误的输入错误,但这不是问题,我刚刚找到了解决方案。
【解决方案2】:

基于此处发现的相同问题:

VS 2010 Error “Object reference not set to an instance of an object” when adding Service Reference for WCF Service

问题是在同一个解决方案中有一个同名的服务引用。 删除包含它的项目后,我设法添加了引用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多