我正在尝试创建自定义行为扩展来设置凭据。但是,正如许多其他我得到的加载异常告诉我它无法加载特定的扩展。我非常确定完全限定名称拼写正确。
<extensions>
<behaviorExtensions>
<add name="UserNameClientCredentials" type="Namespace.UserNameClientCredentials, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
像这样说:
<behaviors>
<endpointBehaviors>
<behavior name="basicAuthenticationBehavior">
<UserNameClientCredentials UserName="test" Password="tttttt"/>
</behavior>
</endpointBehaviors>
</behaviors>
从端点开始:
<endpoint address="https://localhost:8080" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding"
contract="MyContract" name="endpointName"
behaviorConfiguration="basicAuthenticationBehavior"/>
这将导致以下异常:
Exception thrown: 'System.Configuration.ConfigurationErrorsException' in System.Configuration.dll
Additional information: The type ....... registered for extension 'UserNameClientCredentials' could not be loaded.
我没有运气的尝试:
将程序集添加到Common7 / IDE文件夹
确保DLL与可执行文件位于同一目录中。我甚至用dotPeek将它解压缩,以确保该类在那里!
从配置文件中设置ClientCredentials的任何建议或替代方法?