我有我的所有连接从我的代码设置,而不是使用我的配置文件。如何设置WCF跟踪从代码构建的连接。我尝试将配置文件添加到配置文件中,如here所述,但它不会生成任何日志。代码WCF跟踪
我需要知道如何让它在代码中设置的连接的配置文件中工作,或者如果任何人有任何信息,如何在代码中手动配置它。谢谢!
编辑:要添加一点点的更多信息:
应用程序是一个C#控制台应用程序,和我的结合被声明为:
private Binding getBinding()
{
NetTcpBinding tcp = new NetTcpBinding();
tcp.ReaderQuotas.MaxArrayLength = 65535;
tcp.TransferMode = TransferMode.Streamed;
tcp.ReaderQuotas.MaxArrayLength = int.MaxValue;
tcp.ReaderQuotas.MaxDepth = int.MaxValue;
tcp.ReaderQuotas.MaxStringContentLength = int.MaxValue;
tcp.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
tcp.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
tcp.MaxReceivedMessageSize = int.MaxValue;
return tcp;
}
而我则使用通用到我的应用程序添加服务功能:
private List<ServiceHost> m_Hosts = new List<ServiceHost>();
private static List<string> m_Services = new List<string>();
public void AddHost<T1, T2>(string uri)
where T1 : class
where T2 : class
{
m_Services.Add("net.tcp://<ipaddress>:<port>/" + uri);
m_Hosts.Add(new ServiceHost(typeof(T1)));
m_Hosts[m_Hosts.Count - 1].AddServiceEndpoint(typeof(T2), getBinding(), m_Services[m_Services.Count - 1]);
}
显然有更多的代码,使这一切工作,但这应该给任何相关的部分。
你要确保了'initializeData ='属性的文件夹中有一个文件名您的服务可写入的位置。否则什么都不写。 – 2009-12-18 19:58:51
什么也没有......它不会抛出任何异常或任何东西,但它也不会创建日志文件。 – 2009-12-18 20:21:08
@ md5sum:你能检查你的'app.config'文件是否被主机应用程序读取?例如,尝试在'app.config'中添加' appSettings>'并尝试使用'System.Configuration.ConfigurationSettings.AppSettings [“TEST_KEY “]'来自主机应用程序。 –
2009-12-18 23:07:32