wcf client configuration - wcf

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

Related

Asp.net Hosted Blazor - Can i use app.config or web.config?

Im looking to add a web.config (or app.config) so that i can have different settings (e.g. DEV build vs RELEASE build, for instance).
Can i simply add a .config file and expect to read from it?
I noticed that there is also an option to add a appsettings.json (App Settings File).
Which one of these should i be using for Blazor Client app (hosted via Asp.net)?
Thanks
Updates
Based on the following thread, i might just go with a settings
file on the Server side and feeding it to the Client via API.
Here is another reference for appsettings.json vs web.config
I was able to find a more concrete example int this article.
I believe you can use appsettings.Development.json and appsettings.json
Hope this helps...

wcf routing - how to edit config file programatically at runtime

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.

How to deactivate a service under an IIS host

I have more WCF services under an IIS virtual directory. I have to deactivate some of them and I thought, I have just commet out the appropriate sections in the web.config, but it seems not, the client works. Just in the browser comes the error message, that the metadata is not reachable.
Is it actually possible to somehow deactivate the services?
I had an another idea, to rename the .svc files, but I want to avoid that solution.
I am using .Net 4.0.
I've found that:
Simplified Configuration for WCF Services:
http://msdn.microsoft.com/en-us/library/ee530014%28v=vs.100%29.aspx
If you have only one service in the Web application, you may simply stop the app pool associated with the service, provided you have one app pool per web application.
If you have more than one services in the application and you just want to deactivate one,you may remove the respective svc file; or if you use config activation without any svc file, you may comment out respective line in the config. For more details about how to activate services without SVC files, you may read http://www.codeproject.com/Articles/627240/WCF-for-the-Real-World-Not-Hello-World and check the source codes attached in the article.

Is it possible to rewrite silverlight application resources at runtime?

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!

SharePoint 2010 WebPart Configuration File

Where is it best practice to set up the configuration such as connection strings or web service URL's in SharePoint 2010's Web Parts?
Web parts do not contain a web.config or an app.config and for good reason. So i wanted to know what everyone else does.
Would it be a good idea to create another assembly file along with your project?
Bill.
WebPart refers the configuration file web.config of the Web Site where it is deployed to. So we all use web.config for storing all the configuration.
Below Links will help you to get the value from the Web.Config
To Read Connection String.
To Read application Settings.