04 December 2007

WCF - The remote server returned an unexpected response: (400) Bad Request.

The WCF fault "The remote server returned an unexpected response: (400) Bad Request.", might be caused by some quota or timeout on server / client side.The solution is to increase reader quota values from binding configuration on both sides:

<bindings>
<wsHttpBinding>
    <binding name="WSHttpBinding_IService" closeTimeout="00:01:00" 
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
    maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000"
    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
    allowCookies="false">
        <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000"
        maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
        <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
        <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
            algorithmSuite="Default" establishSecurityContext="true" />
        </security>
    </binding>
</wsHttpBinding>
</bindings>
<services>
    <service name="MyService" behaviorConfiguration="MyServiceTypeBehaviors">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" contract="MyIService"/>
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
     </service>
</services>

30 November 2007

14 March 2007

Visual Studio 2005 Code Snippets

IntelliSense Code Snippets are reusable, task-oriented blocks of code. Visual Studio 2005 has some code snippets. There are some additional Code Snippets

Download, install and enjoy.

10 January 2007

Visual Studio 2005 SP1, dotnetfx 3.0, LINQ => Refactoring gone

I installed Visual Studo 2005 SP1, dotnet 3.0, Visual Studio Code Name "Orcas" and LINQ.
When I wanted to use the refactoring the SmartTags stopped working and the Refactor option was missing!!!
I needed to refactor some .net 2.0 code and even nothing.
So I went googling and found the solution here!!!
Only the last option worked for me :)

The steps are:
1) Launch regedit.exe
Open HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Packages\{A066E284-DCAB-11D2-B551-00C04F68D4DB}\SatelliteDLL
Edit the "Path" value and change it from "C:\Program Files\Microsoft Visual Studio 8\VC#\VCSPackages\1033\" to "C:\Program Files\Microsoft Visual Studio 8\VC#\VCSPackages\"
Restart Visual Studio and see if these problems are fixed?

2) Open a command prompt, go to
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
Run
(i) devenv /setup
(ii) devenv /resetuserdata
(iii) devenv /resetsettings CSharp

When installing orcas / LINQ, be afraid, be very afraid.

02 January 2007

How to Pad Left a number?

Padding left a number using SQL Server is implemented using the REPLICATE TSQL function.
Here is an example to format a date:
DECLARE @Date VARCHAR(8)
SET @Date = CAST(YEAR(GETDATE()) AS VARCHAR(4))
SET @Date = @Date + REPLICATE('0', 2 - DATALENGTH(CAST(MONTH(GETDATE()) as VARCHAR))) + CAST(MONTH(GETDATE()) as VARCHAR) 
SET @Date = @Date + REPLICATE('0', 2 - DATALENGTH(CAST(DAY(GETDATE()) as VARCHAR))) + CAST(DAY(GETDATE()) as VARCHAR) 
SELECT @Date


Create a SQL Server function for padleft and padright and you job will be simplefied. Here is a good place to start.