views:

327

answers:

1

I have certain strings which contain special characters so they can not be shared as enum members across a WCF service. (Actually, they are keys for configuration values.)

I want to be able to pass in the keys at client side and get back the config values. If there is a change, I only want to change the config keys at one place.

Constants would be ideal, because they can be changed as strong references across the entire solution, and the underlaying value could be updated with a service reference update.

Currently I can think of two possible solutions:

  1. Create a shared assembly and place the constants there
  2. Share the constants across the service.

The problem is, I can't get the datacontractserializer to serialize the constants. Is that possible at all? Is the shared assembly the only option I have?

+2  A: 

If it were me, I'd be keeping my config values in an external config file. You can store the key/value pairs in the config file and then allow all your assemblies to access the file. That way, config values can be changed without re-compiling your assemblies, and can be accessed from any of your services simultaneously.

Justin Niessner
I agree with justin if they're likely to change, otherwise go with the shared assembly as the number of objects you'll share in the future are likely to increase.
Tanner