.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Reconnect WCF klient useing app.config settings

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :WCF



I have a webservice with a reconnect button in the client. I'd like to implement the reconnect function. I have seen a lot of example how to reconnect but all of them implements it with setting the endpoint and everything in the code.

When open my client it uses the app.config settings to open the WCF channel. Actually I'm not a developer so I don't really understand how. I just instantiating my implemented webservice class and it do the job itself.

Is it possible to reopen channel / reconnect using the app.config settings without setting everything in code? Or do I have to set in the code every parameter?




I'm not a development! I'm an infrastructure engineer! Please be patient on the development forums! :)

View Complete Post

More Related Resource Links

Using web.config settings in a


Hi there,

I understand that one can specify a connection string in an <asp:SqlDataSource /> tag, like so:

<asp:SqlDataSource ID="sds" runat="server" ConnectionString="<%$ ConnectionStrings:LiveConnectionString %>" SelectCommand="SELECT Col1 FROM MyTable"></asp:SqlDataSource>

Is there a similar way to specify the table used in the SELECT command?  The following doesn't work for me:

<asp:SqlDataSource ID="sds" runat="server" ConnectionString="<%$ ConnectionStrings:LiveConnectionString %>" SelectCommand="SELECT Col1 FROM <%$ AppSettings:NewContentsListSQLTable %>"></asp:SqlDataSource>

I see from a previous post (http://forums.asp.net/p/1325626/2646097.aspx) that it's possible to set parameter values from web.config settings, so I'd hope you could specify the table (or columns etc.) as well!

All advice gratefully received.

Convert user.config to database storage via my custom settings provider



I've created my own custom settings provider to save user settings (formerly in the user.config) to a database. To point the particular settings that are to be saved to the database I specified

for each property to point to the BlobSettingsProvider instead of allowing them to default to the LocalFileSettingsProvider.
Now I need to convert existing user.configs to save to the database on the fly - a one time conversion. Because I've now specified the properties to use the BlobSettings provider they can no longer access the local user.config.
Does anyone have any thoughts on how best to accomplish this conversion (i.e. read the local user.config and populate the BlobSettingsProvider). The app can be run as a ClickOnce installed app or as a simple .net app - finding the correct local user.config looks to be a problem.
Thoughts, ideas,...?


Encrypt App.config for SMTP settings


Hi all,

I need to encrypt SMTP settings in the app.config file.I also read MSDN article that uses RSA also to encrypt/decrypt.
This is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace EncryptionDecryptionCA
  public class Program
    private static void ProtectConfiguration()
      // Get the application configuration file.
      Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

      // Define the Rsa provider name.
      string provideRsa = "RsaProtectedConfigurationProvider";


First WCF Connection Slow and Proxy Settings in app.config file


I'm new to the WCF and currently facing problems with my first connection to a service we created to connect an Excel OBA to SAP. The first connection is extremely slow, approximately 20 seconds, but once it is establish everything goes really quick afterwards. I've read through some posts and seems like the proxy settings could have an impact. I'm pasting the code of my app.config file below, can you please let me know how I should modify it to include proper proxy settings to improve the first connection?

Also, the proxy thing is just a guess, is there anything else I could do to improve this? Any hint would be appreciated.

Thanks a lot!






xml version

hard code app.config settings in class



I wonder how to hard code the configuration below in a class. I have a case where I cannot use app.config (due to creation of dll).  The code below is probably not enough..any help is appreciated. Thanks in advance.

hard coded in class

ContractDescription contract = new ContractDescription("Common.MyInterfaces.IConnector");

Binding binding = new NetTcpBinding();

binding.Name = "net.tcp.binding";

EndpointAddress endPointAddress = new EndpointAddress("net.tcp://localhost:9001/Connector");

ServiceEndpoint serviceEndpoint = new ServiceEndpoint(contract, binding, endPointAddress);






        <binding name="net.tcp.binding"></binding>





        <behavior name

web.config has incorrect settings for the requestFiltering element


HI! When I upgrade from wss 3.0 to sharepoint foundation 2010, i find this error and the error is shown below:

Web.config file has incorrect settings for the requestFiltering element.

The requestFiltering element in web.config must have the allowDoubleEncoding attribute set to true in order to support file names with the + character in them. Also, it must have a child requestLimits element with the maxAllowedContentLength attribute set to 2147483647 to avoid interfering with file uploads.

Ensure the requestFiltering element exists in web.config, that its allowDoubleEncoding attribute is set to true, that it has a child requestLimits element, and that its maxAllowedContentLength is set to 2147483647. For more information about this rule, see "http://go.microsoft.com/fwlink/?LinkID=163442".


In the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\web.config, the maxAllowedContentLength is already set to 2147483647. 

Does anyone have any idea?


Service throttling behaviour app.config settings

How can I calculate the MaxConcurrentSessions, MaxConcurrentCalls and maxConcurrentInstances properties to set in the app.config ? I believe it should have some dependency on the # of CPU and the Max and Min worker threads based on which these parameters can be set.

Can you please guide me how can I provide them the number for these properties like we could calculate for ASP.NET.

Clean Web.Config Files (VS 2010 and .NET 4.0 Series)

.NET 4 includes a new version of the CLR, and a new .NET 4 specific machine.config file (which is installed side-by-side with the one used by .NET 2, .NET 3 and .NET 3.5).

The new .NET 4 machine.config file now automatically registers all of the ASP.NET tag sections, handlers and modules that we've added over the years, including the functionality for:

.ASP.NET Dynamic Data
.ASP.NET Routing (which can now be used for both ASP.NET WebForms and ASP.NET MVC)
.ASP.NET Chart Control (which now ships built-into ASP.NET V4)
What this means is that when you create a new "Empty ASP.NET application" project in VS 2010, you'll find that the new default application-level web.config file is now clean and simple:

Convert English to Arabic number without changing any regional settings in .net

Well, most applications that I worked with was multilingual that supports English UI and Arabic UI.

And one of the major issue that we have faced is displaying Arabic numbers without the need of changing the regional settings of the PC.

So the code below will help you to display Arabic number without changing any regional settings.

validateRequest appears to be kicking in in MVC RC1 despite settings

After upgrading a project to the RC a System.Web.HttpRequestValidationException is thrown when posting a value containing HTML from a TextArea. I have checked that validateRequest=false in Views/web.config, and have set this in the application's root web.config. I have also created a fresh MVC project, created a simple view & controller and posted a simple html paragraph element with the same result. Call stack provided. [HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (html="

hello world

").] System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) +8718538 System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName) +111 System.Web.HttpRequest.get_Form() +129 System.Web.HttpRequestWrapper.get_Form() +11 System.Web.Mvc.ValueProviderDictionary.PopulateDictionary() +113 System.Web.Mvc.ValueProviderDictionary..ctor(ControllerContext controllerContext) +74 System.Web.Mvc.ControllerBase.get_ValueProvider() +31 System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +53 System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +109 System.W

reading values from config files in NUnit tests


One of my NUnit tests has to read in some values from config files.  In my main application this process works perfectly well, however when I run the unit test, the code that reads in the values from the config files doesnt read anything in.  Ive tried putting app.config in my unit test project (I even tried web.config) but nothing seems to work.  Are there any special steps involved when reading from config files in an nunit test ?

NUnit and config files


Ive created an NUnit test project in my solution and have added 3 tests.  They all fail with the same error

SetUp : System.TypeInitializationException : The type initializer for 'Systems.Utils.ConstantHelpers' threw an exception.
  ----> System.NullReferenceException : Object reference not set to an instance of an object.


SetUp : System.TypeInitializationException : The type initializer for 'Systems.Utils.ConstantHelpers' threw an exception.

  ----> System.NullReferenceException : Object reference not set to an instance of an object.

heres the test method

        public void CreateDataContext_ConnectionString_ReturnsDataCon

Modifying connection String in Web config using Install Wizard



Im trying to create a Web Deployment Project, the built in setup and deployment is very good in Visual Studio, i need to able to add an additional step in the setup to change the connection string in the Web config file. Ive seen a lot of articles on how to do this and in particular this http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx#7162670 I am however stuck on the final part of this tutorial, im using the code Scott provided but have two errors,  heres part of my code where the errors are

using System;
using System.Configuration;
using System.Configuration.Install;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.DirectoryServices;

 void ConfigureDatabase(string targetSite, string targetVDir, string connectionString)
            // Retrieve "Friendly Site Name" from IIS for TargetSite
            DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/" + targetSit

Web deployment project - web.config section replacement does not add remove tag


I have a web application that is actually installed as a component of a third party site.  In some configurations, I need to remove certain connection strings and re-add them.  I'm replacing this web.config section with a xml file that includes the following:

      <remove name="MyOverridenConnection"/>
      <add connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDb;Data Source=MyServer" name="MyOverridenConnection"

For some reason the remove tag is left out during the substitution and I end up with the following in the installed config:

      <add connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDb;Data Source=MyServer" name="MyOverridenConnection"

Is there any way to issue removes in replaced sec

Web Deployment with IIS settings of remote server


Im trying to deploy a web application project (VS 2010) via team build (TFS 2010), i got to use IIS settings of development server for deployment. So from the project properties I configured the web projects to use Custom web server, (enabled radio button), once i do this the Option in the tab Package/Publish Web "Include all IIS Settings as configured in IIS manager" gets disabled and as a result the deployed web project does not have this IIS settings.

What am I missing here, Im not using the option "Use local IIS Web Server" because the build happens in a build server and would try to take local IIS settings for packaging which is not present.

If this is not possible, suggest me any workaround. Any help on this is greatly appreciated.

The ASP Column: What's in ASP.NET Config Files?


Even though you've been using ASP. NET for a while, how much do you really know about ASP. NET configuration files? While you've probably touched the Web. config file from time to time, there are some nuances involved in configuring ASP.

George Shepherd

MSDN Magazine September 2004

User Preferences: Manage User Settings in Your .NET App with a Custom Preferences API


There are plenty of options out there for managing user preferences including custom configuration files, the Windows registry, and the isolated storage. But each option has its pros and cons -- and a bad choice can make life difficult. In this article, the author evaluates various options and identifies the characteristics of a good preferences API. Based on those characteristics, he introduces an API that is specifically designed for preferences management, one that offers the best of all the options.

Ray Djajadinata

MSDN Magazine July 2004

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend