You can change it at runtime. But that would be a lot of work, and it should have happened before the service began. After starting the service, you cannot change the contract information.
Personally, I do not like the start of the service, depending on the database. If something breaks, the service never appears, and troubleshooting can be a difficult process for IT. If I needed to run the execution route, I would save the namespace value in my configuration file. It just keeps it simple and still allows you to replace the token after deployment, like what you describe in your question.
From the comments, you indicate the build process. Here's how we handle this: make the namespace a constant string. For example:
[DataContract(Namespace=Constants.CURRENT_NAMESPACE] public class MyClass { }
Now in a separate file, declare:
// in a separate file define: public static class Constants { public const string CURRENT_NAMESPACE = "url://Services"; };
If you want to create for another environment, replace the Constants file for the new definition:
It is easy to manage, you always know what namespace is used ... and the service always starts. It works?
source share