问题:

我在我的解决方案中创建了一个WCF服务库项目,并提供了对此的服务引用。 我使用类库中的服务,所以除了类库之外,我还有来自WPF应用程序项目的引用。 服务直接设置 – 仅更改为获取异步服务功能。

一切都很好 – 直到我想更新我的服务参考。 它失败了,所以我最终回滚并重试,但即便如此也失败了! 因此 – 更新服务引用失败而不对其进行任何更改。 为什么?!

我得到的错误就是这个:

Custom tool error: Failed to generate code for the service reference 
'MyServiceReference'.  Please check other error and warning messages for details.   

警告提供了更多信息:

Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: 
System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: List of referenced types contains more than one type with data contract name 'Patient' in  
namespace 'http://schemas.datacontract.org/2004/07/MyApp.Model'. Need to exclude all but one of the 
following types. Only matching types can be valid references: 
"MyApp.Dashboard.MyServiceReference.Patient, Medski.Dashboard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" (matching)
"MyApp.Model.Patient, MyApp.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" (matching)
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISomeService']

有两个类似的警告也说:

Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISomeService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='WSHttpBinding_ISomeService']  

同样的:

Custom tool warning: Cannot import wsdl:port .. 

我发现这一切都令人困惑。除了我通过服务参考获得的那个,我在客户端仪表板上没有Patient类。 那是什么意思呢? 为什么突然显示出来? 记住:我甚至没有改变任何东西!

现在, 这里找到了解决方案,但没有解释这意味着什么。 所以; 在服务的“配置服务引用”中,取消选中“在引用的程序集中重用类型”复选框。 重建现在一切正常,没有问题。 但是我真正改变了什么呢? 这会对我的申请产生影响吗? 什么时候应该取消选中? 我确实想重用我已经设置DataContract的类型,但没有更多。 我仍然可以访问那些没有经过检查的人吗?

I created a WCF service library project in my solution, and have service references to this.I use the services from a class library, so I have references from my WPF application project in addition to the class library.Services are set up straight forward – only changed to get async service functions.Everything was working fine – until I wanted to update my service references.It failed, so I eventually rolled back and retried, but it failed even then!So – updating the service references fails without doing any changes to it.Why?!The error I get is this one:The warning gives more information:There are two similar warnings too saying:And the same for:I find this all confusing.. I don’t have a Patient class on the client side Dashboard except the one I got through the service reference.So what does it mean?And why does it suddenly show?Remember: I didn’t even change anything!Now, the solution to this was found here , but without an explanation to what this means.So;in the “Configure service reference” for the service I uncheck the “Reuse types in the referenced assemblies” checkbox.Rebuilding now it all works fine without problems.But what did I really change?Will this make an impact on my application?And when should one uncheck this?I do want to reuse the types I’ve set up DataContract on, but no more.Will I still get access to those without this checked?

问题:

当我尝试启动在C#中创建的Windows服务时出现此错误:

替代文字

到目前为止,我的代码:

private ServiceHost host = null;

public RightAccessHost()
{
    InitializeComponent();
}

protected override void OnStart(string[] args)
{
    host = new ServiceHost(typeof(RightAccessWcf));
    host.Open();
}

protected override void OnStop()
{
    if (host != null)
        host.Close();
    host = null;
}

更新#1

我通过向帐户NETWORK SERVICE授予权限解决了上述问题,但现在又遇到了另一个问题:

替代文字

更新#2

服务无法启动。 System.InvalidOperationException:服务’RightAccessManagementWcf.RightAccessWcf’具有零个应用程序端点(非基础结构)。 这可能是因为没有为您的应用程序找到配置文件,或者是因为在配置文件中找不到与服务名称匹配的服务元素,或者因为在服务元素中未定义端点。 在System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreNonMexEndpoints(ServiceDescription描述)在System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription描述,ServiceHostBase serviceHost)在System.ServiceModel.ServiceHostBase.InitializeRuntime()在System.ServiceModel.ServiceHostBase.OnOpen()在System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan超时)在C:\\ Users中的RightAccessHosting.RightAccessHost.OnStart(String [] args)处。

I’m getting this error when I try to start a windows service I’ve created in C#:My Code so far:Update #1I solved the issue above by granting permissions to the account NETWORK SERVICE but now I have an another problem:Update #2Service cannot be started.System.InvalidOperationException: Service ‘RightAccessManagementWcf.RightAccessWcf’ has zero application (non-infrastructure) endpoints.This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.at System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreNonMexEndpoints(ServiceDescription description) at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) at System.ServiceModel.ServiceHostBase.InitializeRuntime() at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at RightAccessHosting.RightAccessHost.OnStart(String[] args) in C:\\Users….

问题:

任何想法如何解决这一问题?

UserService.UserServiceClient userServiceClient = new UserServiceClient();
            userServiceClient.GetUsersCompleted += new EventHandler<GetUsersCompletedEventArgs>(userServiceClient_GetUsersCompleted);
            userServiceClient.GetUsersAsync(searchString);

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_UserService" 
                     maxBufferSize="2147483647" 
                     maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:52185/UserService.svc" 
                  binding="basicHttpBinding" 
                  bindingConfiguration="BasicHttpBinding_UserService" 
                  contract="UserService.UserService"
                  name="BasicHttpBinding_UserService" />
    </client>
    <behaviors>
        <serviceBehaviors>
            <behavior name="Shell.Silverlight.Web.Service3Behavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <services>
        <service behaviorConfiguration="Shell.Silverlight.Web.Service3Behavior" 
                 name="Shell.Silverlight.Web.Service3">
            <endpoint address="" 
                      binding="basicHttpBinding" 
                      contract="Shell.Silverlight.Web.Service3" />
            <endpoint address="mex" 
                      binding="mexHttpBinding" 
                      contract="IMetadataExchange" />
        </service>
    </services>
</system.serviceModel>

无法在ServiceModel客户端配置部分中找到引用合同“UserService.UserService”的默认端点元素。 这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。

解决!

我没有提到这是一个Silverlight应用程序。 我在DLL中有wcf引用,它有自己的“ServiceReferences.ClientConfig”文件。 我将DLL的ServiceReferences.ClientConfig的内容移动到主Silverlight项目并且它工作了。

Any ideas how to fix this?.Could not find default endpoint element that references contract ‘UserService.UserService’ in the ServiceModel client configuration section.This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.Resolved!I didn’t mention that this was a Silverlight application.I had the wcf reference in a DLL which had it’s own “ServiceReferences.ClientConfig” file.I moved the contents of the DLL’s ServiceReferences.ClientConfig to the main silverlight project and it worked.

问题:

我构建了一个包含WCF服务契约和Silverlight控件的Web应用程序,该控件调用该WCF服务。 在我的开发和测试服务器上它运行良好。

当我部署到我们的实时服务器并运行应用程序时,我得到System.ServiceModel.ServiceActivationException类型的异常,该异常表明由于编译期间的异常而无法激活该服务。 例外是:

此集合已包含方案http的地址。 此集合中每个方案最多只能有一个地址。

我读到如果网站有多个主机头,则可能抛出此异常,这在我们的实时服务器上是正确的。 显然,IIS中托管的WCF服务只能有一个基地址。 我该如何解决这个问题?

I built a web application containing a WCF service contract and a Silverlight control which makes calls to that WCF service.On my development and test servers it works great.When I deploy to our live server and run the application I get an exception of type System.ServiceModel.ServiceActivationException which states that the service can not be activated due to an exception during compilation.The exception is:This collection already contains an address with scheme http.There can be at most one address per scheme in this collection.I read that this exception may be thrown if the web site has more than one host header, which is true on our live server.Apparently WCF services hosted in IIS can have only one base address.How can I get around this issue?