WCF クライアントで問題が発生しています。endpointBehaviors を構成しましたが、Servicehost に読み込まれません (ただし、バインディングは読み込まれました...)。
構成:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="DefaultBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="DefaultBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="..." behaviorConfiguration="DefaultBehavior" binding="netTcpBinding" bindingConfiguration="DefaultBinding" contract="..." name="..."/>
<endpoint address="..." behaviorConfiguration="DefaultBehavior" binding="netTcpBinding" bindingConfiguration="DefaultBinding" contract="..." name="..."/>
</client>
</system.serviceModel>
ServiceWrapper クラス:
public class ServiceWrapper<T> : IDisposable where T : class
{
private ChannelFactory<T> factory;
private T channel;
private readonly NetTcpBinding binding;
private readonly EndpointAddress endpoint;
private readonly object lockObject = new object();
private bool disposed;
public ServiceWrapper(string configName)
{
ClientSection clientSection = ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection;
ChannelEndpointElementCollection endpointCollection = clientSection.ElementInformation.Properties[string.Empty].Value as ChannelEndpointElementCollection;
foreach (ChannelEndpointElement endpointElement in endpointCollection)
{
if (endpointElement.Name != configName)
continue;
binding = new NetTcpBinding(endpointElement.BindingConfiguration);
endpoint = new EndpointAddress(endpointElement.Address);
disposed = false;
}
if (endpoint == null)
throw new ConfigurationErrorsException(configName + " is not present in the config file");
}
public T Channel
{
get
{
if (disposed)
throw new ObjectDisposedException("Resource ServiceWrapper<" + typeof(T) + "> has been disposed");
lock (lockObject)
{
if (factory == null)
{
factory = new ChannelFactory<T>(binding, endpoint);
channel = factory.CreateChannel();
}
}
return channel;
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
lock (lockObject)
{
if (channel != null)
((IClientChannel)channel).Close();
if (factory != null)
factory.Close();
}
channel = null;
factory = null;
disposed = true;
}
}
}
}
どうやって先に進むか本当にわかりません。誰かがそれを機能させる方法についてアイデアを持っていますか?
どうも