Archive for the 'Configuration' 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

03
Aug
10

System.ArgumentException: The provided URI scheme ‘file’ is invalid; expected ‘http’.

If you are using Silverlight RIA Services application, you might get this error sometimes. Simple reason is you have set the Silverlight application as a Startup project. When Silverlight project is startup project it will generate a test html page and loads it from file system rather than in http mode. So simple fix is to set the Website that hosts the RIA context as startup project!

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 :)

26
Nov
09

enabling Async methods for wcf in wpf

By default when you add a WCF Service reference in WPF, it does not give async functions. If your application needs async features, while adding a reference to the service, lookout for a ‘Advanced’ button on Add service reference window at bottom right corner. On clicking on that button, a new window appears. There is a checkbox called ‘Generate Asynchronous Operations’. Hit Ok and you are done!

Simple isn’t it :)

24
Nov
09

if you need to send more data to wcf service

For example, you need to upload log file in case of error from desktop application to remote site using WCF service and if the log file is too big, you might have to tweak your WCF service’s Web.config.

By default the configuration for the service will be

      <services>
            <service behaviorConfiguration="ServiceBehavior" name="Service">
                <endpoint address="" binding="basicHttpBinding" contract="IService">
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>

You need to specify the binding manually and add binding reference as highlighted below.   

 

    <services>
            <service behaviorConfiguration="ServiceBehavior" name="Service">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" contract="IService">
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <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>

That’s it :) Simple isn’t it?

16
Nov
09

multiline textbox in wpf

As a windows forms application/web application developer you might be looking for MultiLine property while developing in WPF. You will be surprised to see that there is no property like that.

Trick is you have to set AcceptsReturn="True" TextWrapping="Wrap" and VerticalScrollBarVisibility="Auto" to get yourself a multiline textbox

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 :)

06
Nov
09

IIs7 wcf configuration

If you are seeing 404- file not found error for your favorite svc file on IIS7

execute this in command prompt

C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -i

Yeppie… your svc files work like charm :)




@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.