embed app config into c# code in wcf
c#, configuration, wcf, wcf-client, wcf-configuration
Solution
Yes you can configure all of the settings for the WCF in code. Searching the stackoverflow I found a link were this questions has been asked wcf-configuration-without-a-config-file Also there is a link from the Microsoft MSDN MSDN Source. About the tracing of the WCF here is a link that also will help you:WCF Tracing in code
Problem
i have a client program that connect to my wcf service. i want to embed app config to C# code till users can not change or even see app.config . but i cannot bring these two config setting to C# code: ``` <system.diagnostics> <sources> <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning"> <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="Default"> <filter type="" /> </add> <add name="NewListener"> <filter type="" /> </add> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing" > <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="Default"> <filter type="" /> </add> <add name="NewListener"> <filter type="" /> </add> </listeners> </source> </sources> <sharedListeners> <add initializeData="Trace.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="NewListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack"> <filter type="" /> </add> </sharedListeners> </system.diagnostics> ``` And ``` <system.net> <defaultProxy enabled="true" useDefaultCredentials="true" > <proxy autoDetect="True" usesystemdefault="True"/> </defaultProxy> </system.net> ``` i added some code like this ``` System.Diagnostics.XmlWriterTraceListener xmlt = new System.Diagnostics.XmlWriterTraceListener("Trace.svclog", "myListener"); System.Diagnostics.Trace.Listeners.Add(xmlt): ``` but did not work . when you set Trace Listener in app.config File , The application will automatic log exception,Warning,etc occured (That i want) but when i create System.Diagnostics.XmlWriterTraceListener i must write log (exceptions) my self. about default proxy i found some classes but i can not find those setting in classes. Questions : 1- I want to bring these Settings to C# code.(i want C# result be exact like app.config result) 2- is the app.config Stronger than C# code? can i find all app.config settings in c# classes?