gpt4 book ai didi

c# - 听到 "element ' 行为“具有无效的子元素”应该被忽略,但因此无法更新服务引用

转载 作者:行者123 更新时间:2023-11-30 16:25:50 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
The element ‘behavior’ has invalid child element ‘myFaultExtension’ in wcf app.config

我正在尝试实现 Creating and Handling Faults in Silverlight . (This 项目在我的机器上运行。)

我收到 Visual Studio 警告:

The element 'behavior' has invalid child element 'betterErrorMessagesFaults'.

其他地方的其他答案说我应该忽略它,但我不能,因为我无法更新非 .Web 项目(包含所有 xaml 文件的项目)中的服务引用。当我尝试时,出现此错误:

Parser Error Message: The type 'MyProject.Web.Services.BetterErrorMessagesFaultBehavior, MyProject.Web.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'betterErrorMessagesFaults' could not be loaded.

这是 Web.config 的相关部分:

<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="betterErrorMessagesFaults"
type="MyProject.Web.Services.BetterErrorMessagesFaultBehavior, MyProject.Web.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
<services>
<service name="MyProject.Web.Services.Service2">
<endpoint address="" binding="customBinding"
bindingConfiguration="MyProject.Web.Services.Service2.customBinding0"
contract="MyProject.Web.Services.Service2"
behaviorConfiguration="BetterErrorMessagesFaultBehavior"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="BetterErrorMessagesFaultBehavior">
<betterErrorMessagesFaults/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="MyProject.Web.Services.Service2.customBinding0">
<binaryMessageEncoding>
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxDepth="2147483647" maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binaryMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

BetterErrorMessagesFaultBehavior 只是类 here on MSDN 的复制粘贴;仅更改名称(我也尝试使用默认名称),并将命名空间更改为 MyProject.Web.Services

我也试过交换

<add name="betterErrorMessagesFaults" 
type="MyProject.Web.Services.BetterErrorMessagesFaultBehavior, MyProject.Web.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>

<add name="betterErrorMessagesFaults" 
type="MyProject.Web.Services.BetterErrorMessagesFaultBehavior, MyProject.Web.Services"/>

但是没有效果。我读到这对空格等非常敏感,但我看不到任何问题区域。我还查看了 AssemblyInfo,版本是 1.0.0.0,culture 是空白 (""),我不知道 PublicKeyToken 是做什么用的,但我怀疑这不是这里的问题...

所以我很困惑,不知道下一步该往哪里看。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com