pondelok 27. februára 2012

Error: The maximum message size quota for incoming messages (65536) has been exceeded.

This error has occurred, when I was calling simple method on WCF service.
I double checked my web.config on server side (IIS) and everything was fine.

But!!! the size 65536 was in client app.config! The client configuration was not reflecting server WCF configuration, changing maxReceivedMessageSize to e.g. 2147483647 is solution.


Code Snippet
  1. <system.serviceModel>
  2.     <bindings>
  3.       <basicHttpBinding>
  4.         <binding name="BasicHttpBinding_IeDocsInterfaceCUD" closeTimeout="00:10:00"
  5.           openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
  6.           allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
  7.           maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
  8.           messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
  9.           useDefaultWebProxy="true">
  10.           <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
  11.             maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  12.           <security mode="None">
  13.             <transport clientCredentialType="None" proxyCredentialType="None"
  14.               realm="" />
  15.             <message clientCredentialType="UserName" algorithmSuite="Default" />
  16.           </security>
  17.         </binding>

piatok 24. februára 2012

Error : There was no endpoint listening... WCF

This error has occurred, when I was sending file to WCF service hosted on IIS 7, with more size than 30MB. There is a security limitation in IIS. After adding this lines in the web.config, the problem has been solved.



Code Snippet
  1. <system.webServer>
  2.        <security>
  3.          <requestFiltering>
  4.            <requestLimits maxAllowedContentLength="2147483647" />
  5.          </requestFiltering>
  6.        </security>
  7.     </system.webServer>

štvrtok 16. februára 2012

An error (The request was aborted: The request was canceled.) occurred while transmitting data over the HTTP channel.

I got this error when transmitting large file (byte array) to WCF service.

I double checked my web.config,

Code Snippet
  1. <bindings>
  2.       <basicHttpBinding>
  3.         <binding
  4.           name="BasicWithMtom"
  5.           maxReceivedMessageSize="2621440"
  6.           messageEncoding="Mtom">
  7.           <readerQuotas maxArrayLength="2621440"/>
  8.         </binding>
  9.       </basicHttpBinding>
  10.     </bindings>

but sizing was good enough.

The problem is, that the WCF service is hosted on IIS and  you need to configure quotas on two separated places!!

Add this:

Code Snippet
  1. <system.webServer>
  2.   <httpRuntime maxRequestLength="2621440" />
  3. </system.webServer>


Everything is working now..

Have a nice day!

pondelok 6. februára 2012

Favorite source code files in Visual Studio

Today I was looking for something like Bookmarks in Firefox or Favorites in IE, but right in the Visual Studio. I found, that it is not native function, but....

Visual Studio Extension called Favorite Documents is exactly, what i was looking for.

Enjoy:

Favorite Documents

Have a nice day!

C# Code to HTML Converter

I used it in my last post.

It's Visual Studio 2010 Extension called Copy as HTMl.

Very simple to use - CTRL - C CTRL - V

Copy as HTML

List of objects to Dictionary

Example of using extension method  ToDictionary.
Maybe you can found this my code  useful.

The first is converting list to dictionary with key-selector.
The second extracts only two atributes (key, val)

Code Snippet
  1. class People
  2.     {
  3.         public string userID { get; set; }
  4.         public string name { get; set; }
  5.         public string phone { get; set; }
  6.         public string email { get; set; }
  7.     }
  8.         
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.            List<People> users = new List<People>();
  14.  
  15.            //p.Add()...
  16.  
  17.  
  18.            Dictionary<string, People> temp =
  19.                               users.ToDictionary(c => c.userID);
  20.  
  21.            Dictionary<string, string> eMails =
  22.                         users.ToDictionary(c => c.userID, c => c.email);
  23.          
  24.         }
  25.     }