There is ServiceReferences.ClientConfig file that holds different settings of WCF services Silverlight application is using. Nice and easy, except once you set them you cannot change them later without modifying a xap.
I want to make these setting configurable with a less pain.
There are several options:
Add a dedicated section in web.config where an administrator could change them. Transfer these settings to silverlight then rendering object on page. Parse it in silverlight, then build channel manually. Something I'd rather avoid.
It would be nice if we could say silverlight application to load ServiceReferences.ClientConfig not from xap resources, but from a specified uri. That way I could place this config along web.config. Nice. Not possible though.
If I could substitute resource stream resolver, that would work too. Sadly it doesn't seem to be possible either. There is IApplicationResourceStreamResolver, but it's internal.
Maybe there is a way to rewrite application resource stream after a silverlight application is started?
I guess you want to make the servicesclient config file at the runtime.
If that is the case then simply create object of System.ServiceModel.BasicHttpBinding and assign properties and assign service URL to System.ServiceModel.EndpointAddress. This binding object and endpointaddress object can be then assigned to the client object constructor and voila!
Related
I'm trying to build a core with the routing service technology (in wcf .net) that discover its clients automatically with DiscoveryService and then write them into the config file with specific filters so that the core will be able to route messages between the clients.
I succeeded to discover the clients with DiscoveryService, but i'm trying to open new config file with the RoutingConfiguration object, and add the new endpoints I discovered through the RoutingConfiguration.filterTable property but it doesn't work. I also tried to look for examples in other sites but i didn't find anything similar.
I don't know if i'm making a mistake, or if I didn't understand well how to open new configuration file and edit it at runtime programatically.
My client insists not to store prone-to-change configuration settings in the Web.Config file for our webservice (WCF). His reasoning is that he will have to deploy the application every time he wants to change this or that setting in the configuration file. He, then, told me to store this configuration information in the database because, he says, that way one can change it whenever one needs without re-deploying the whole application, and because it is a more central place if we ever need to have more than one instance of the service running.
Of course I find this argument and reasoning plainly wrong. However, I would like to provide him with clear evidence in that he his mistaken. Can anyone please point me out a source or two I may site to show him that changes in Web.Config are automatically propagated to the runtime and that he doesn't need to do any kind of re-deployment?
Straight from MSDN on ASP.NET Configuration.
ASP.NET Configuration Overview
ASP.NET detects any changes to the configuration files and then
automatically applies those changes to the affected applications,
restarting the applications in most cases.
See How to: Transform Web.config When Deploying a Web Application Project
I have wcf client. It uses .NET 3.5.
When I compile the client I get two files:
client.exe and
client.exe.config.
The second file contains configuration for the wcf client.
In my case I need to prevent the user sitting on the computer to see the urls and change some other parameters from the config file.
So the requirements are, the end user not to see and modify the data stored in the config. The config file contains the same data as app.config. I need to forbid the person using the program to see the end point urls so easy.
Also I have a lot of configuration there so I do not like to code in the moment.
Is there any solution for the problem (embedded app.config of something else)?
Edit: I do not need configurable options. The config file is automatically created when adding service reference from the studio.
Regards
You can also create your proxies programatically instead of using the service reference feature.
Every parameter in the serviceModel config section can be represented in code as well.
The ChannelFactory class will help you create proxies to the service.
You can easily encrypt entire parts of your config files - and not just web.config in web scenarios, but also application config's in stand-alone apps.
Check out some resources on how to do this:
Encrypting web.config values
Encrypting passwords in .NET app.config file
Encrypting the app.config file for Winforms application
when adding a service reference an app.config is generated. What I'd like to know is, do the bindings, endpoints and everything else reflect the service, that I created the reference to? Do they specifically define that services bindings, security type,..etc, or is it simply a generic app.config? There seem to be a lot of settings..
Yes, the amount of stuff the Add Service Reference wizard dumps in your app.config/web.config is staggering - and largely unnecessary (because it basically puts in all the settings, even all of those that are default values).
Yes, the settings include thing like
binding and binding configuration (parameters like timeouts, proxies etc.)
behaviors (client-side)
client endpoint(s)
If you're interested in learning how to manually create those configs to the bare minimum (which is very easy to do, very easy to understand, too!), watch these videos:
DotNet Rocks TV Show #122: Miguel Castro on Extreme WCF
DotNet Rocks TV Show #135: Keith Elder Demystifies WCF
Both show how easy it is to create manual configs and how little you really need to supply! Highly recommended.
The settings do pertain to the service reference you just created. At least sometimes, the app.config is not useful in itself. For instance, if you are consuming services from a web application, the information in app.config needs to be copied to the appropriate section of web.config to be used.
If the service moves to a different location, you can just change the endpoint in the configuration accordingly, and the service should work as before.
Is it possible to make a WCF reference in a Silverlight DLL private? The option is greyed out and when you edit the Reference.vb file manaully, when running, it complains about not being able to serialize because it is not public.
I don't want the service to be exposed outside of the DLL. Is this possible?
Even though it is generated, you can hack that file up as much as you like, within reason.
What you need to do is declare your generated proxy as internal. You can either do that manually, or you can use the /internal (short form is /i) flag when using svcutil to generate your proxy. (Note that VS doesn't use svcutil when you add a service reference).