Archive for the 'app.config' Category

08
Sep
10

Changing log4net log file path via code

Sometimes we might have to place the log files away from the location where the application is installed. And lo there is an option to do that! In the config file create a variable like below

<file type="log4net.Util.PatternString" value="%property{SomeVariable}log.txt" />

And in the code, before calling log4net configure, set the new path to the Variable

log4net.GlobalContext.Properties["SomeVariable"] = YourNewPath;
log4net.Config.XmlConfigurator.Configure();

Simple isn’t it Smile

14
Jan
10

VS 2010 beta 2 opening applications with error : MSB3134

When you open an already existing full trust application in Visual Studio 2010 beta 2, you might encounter this error after the first build.

MSB3134: The permission set requested by the application exceeded the permissions allowed by the Internet or Intranet zones. Select Full Trust or to continue using partial trust, define your custom permission set in the Security Page of the Project Designer.

This error and the rationale behind it is explained by Kristopher Makey here.

Unfortunately, fix is not clear. Solution is as below.

  • Open <Application>/Properties/app.manifest
  • Remove everything between <security> tag
  • Go to Application Properties > Security tab. Select the permission as ‘Full trust’ and save and compile.

Simple Isn’t it :)

12
Jan
10

wcf service / asmx working with ssl

Sometimes while working with SSL, we will get error ‘The provided URI scheme ‘https’ is invalid; expected ‘http’.’

This is because we might have set Security mode=”None” in web.config/app.config

Change the security mode to Transport. Sample settings is as below

<system.serviceModel>
      <bindings>
          <basicHttpBinding>
              <binding name="PrintRequestSoap"    closeTimeout="01:00:00" openTimeout="01:00:00"
                  receiveTimeout="01:00:00" sendTimeout="01:00:00" allowCookies="false"
                  bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
                  maxReceivedMessageSize="2147483647" messageEncoding="Text"
                  textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                  <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                      maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                  <security mode="Transport">
                      <transport clientCredentialType="None" proxyCredentialType="None"
                          realm="" />
                      <message clientCredentialType="UserName" algorithmSuite="Default" />
                  </security>
              </binding>
          </basicHttpBinding>
      </bindings>
    <client>
      <endpoint address=”asmx/wcf service endpoint"
        binding="basicHttpBinding" bindingConfiguration="PrintRequestSoap"
        contract="PrintDataRequest.PrintRequestSoap" name="PrintRequestSoap" />
    </client>

Simple isn’t it :)

09
Nov
09

if you are expecting too much data from wcf service

Use WCF basicHTTPBinding as the binding. By default it will be wsHTTPBinding

<system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="ServiceBehavior" name="Service">
                <endpoint address="" binding="basicHttpBinding" contract="IService">
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
    </system.serviceModel>

On your client application [web/wpf/silverlight] set the same with maxReceivedMessageSize, maxBufferPoolSize, maxStringContentLength and maxArrayLength to 2147483647 as shown below

<system.serviceModel>
       <bindings>
           <basicHttpBinding>
             <binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
                 openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                 allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647" messageEncoding="Text"
                 textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
               <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                   maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
               <security mode="None">
                 <transport clientCredentialType="None" proxyCredentialType="None"
                     realm="" />
                 <message clientCredentialType="UserName" algorithmSuite="Default" />
               </security>
             </binding>
           </basicHttpBinding>
       </bindings>
       <client>
           <endpoint address="http://yourwebserver/yourservice.svc"
               binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
               contract="ServiceReference1.IService" name="BasicHttpBinding_IService" />
       </client>
   </system.serviceModel>

That should do :)




@pooran

 

May 2012
M T W T F S S
« Nov    
 123456
78910111213
14151617181920
21222324252627
28293031  

Visits so far..

  • 10,471

Follow

Get every new post delivered to your Inbox.