How to disable auto-generated WCF configuration

Posted by user351025 on Stack Overflow See other posts from Stack Overflow or by user351025
Published on 2010-05-30T19:50:35Z Indexed on 2010/05/30 20:02 UTC
Read the original article Hit count: 394

Filed under:
|

Every time my program runs vs adds the default configuration to my app.config file. At that run it works fine, but at the next run it actually tries to read the config.

The problem is that the default configuration has errors, it adds the attribute "Address", but attritbutes are not allowed to have capitals so it throws an exception.

This means I have to remove the bad section every run!

I've tried to configure the .config but it gives errors.

Here is the code that I use to host the server:

private static System.Threading.AutoResetEvent stopFlag = new System.Threading.AutoResetEvent(false);
ServiceHost host = new ServiceHost(typeof(Service), 
                                   new Uri("http://localhost:8000"));
host.AddServiceEndpoint(typeof(IService), 
                        new BasicHttpBinding(), "ChessServer");
host.Open();
stopFlag.WaitOne();
host.Close();

Here is the client code that calls the server:

ChannelFactory<IChessServer> scf;
scf = new ChannelFactory<IService>
              (new BasicHttpBinding(), "http://localhost:8000");
IService service = scf.CreateChannel();

Thanks for any help.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf