Saturday, April 9, 2011

Key Learnings Abdul Azeem Khan

Problem:
While uploading a file by converting file content into array of bytes and sending it to server side via WCF, generates following exception.

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:***. The InnerException message was ‘There was an error deserializing the object of type ****. The maximum array length quota (16384) has been exceeded while reading XML data

Impact:
You will not be able to download or upload file bigger than 1 megabyte.

Solution:
Change the web.config or the app.config file to the following settings.


<bindings>
        <basicHttpBinding>
          <binding
                   maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="0:50:0" openTimeout="0:50:0" receiveTimeout="0:50:0" sendTimeout="0:50:0"
                   >
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2097152"  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </binding>

          </basicHttpBinding>
</bindings>
After this recompile the file and run you application again

Monday, April 4, 2011

Key Learnings Abdul Azeem Khan

Problem: 
While working with ASP.NET ajax toolkit, you get the following exception

" Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure “AjaxControlToolkit.Properties.Resources.resources” was correctly embedded or linked into assembly “AjaxControlToolkit” at compile time, or that all the satellite assemblies required are loadable and fully signed."

Impact:
This will break your website, and it will render is non funcational

Solution:

If you are working with asp.net ajax toolkit extension, The latest incarnation (3.6.097 as of this writing) of the asp.net Ajax Control Toolkit needs to be setup using its script manager and not the standard asp.net Script Manager.

So one way to avoid the above issues is to drag the ToolkitScriptManager (found in the control toolkit) onto the Form tag and then use any other Ajax Controls. Here is an example of it using the TabContainer

<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server"/>
<div>
    <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="1">
        <asp:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1">
            <ContentTemplate><p>Hello</p></ContentTemplate>
        </asp:TabPanel>
        <asp:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2">
        <ContentTemplate><p>Hello2</p></ContentTemplate>
     </asp:TabPanel>
    </asp:TabContainer>
</div>
</form>
 
Hope it help!!!

Saturday, April 2, 2011

Key Learnings Abdul Azeem Khan

Problem:
Intellisense fails to fire up for skin files in any asp.net application

Impact:
This will make it cumbersome to code style rules for standard asp.net server controls and can waste a lot of your time and make your code error prone

Solution:
1. Go to Tools->Options menu.
2. Pick Text Editor -> File Extesion from a tree at the left part of Options dialog.
3. Type skin in Extesion text box.
4. Select User Control Editor from Editor dropdown.
5. Click Add and then Ok to close dialog and re-open your skin files.


 

Wednesday, March 30, 2011

Key Learnings Abdul Azeem Khan

Problem:  
Incorrect Syntax Near “.” during DataAdapter.Fill

Impact:
Your program hangs and you are not able to access the data from the database


Solution:
If you have a SQL statement such as this:
            string statement = "Select title, addDateTime, keyword_id, keyword, lang_id" +
"FROM tableX"; 


the problem is caused due to the lack of space after "lang_id", to solve the problem just put in an extra space, so it would be "lang_id ".
 

Tuesday, March 29, 2011

Key Learnings Abdul Azeem Khan

Problem: 
 java.lang.IllegalAccessException: Class com.sun.xml.ws.fault.SOAPFaultBuilder can not access a member of class Services.CustomException with modifiers "public"

Impact :
When working with custom Exceptions in Web Services, and when you throw them as faults, your Web Service will stall and be no longer funcational.

Solution:

1) Always make a separate package to store your custom exception.
2) Derive your custom exception from Exception class
3) You have to include getFaultInfo() within your custom exception class and this is the key
4) In your @WebMethod include the throws clause and specify the name of your custom exception.

If you follow the steps listed above, there should be no error mentioned above. 

Monday, March 28, 2011

KeyLearnings for Abdul Azeem Khan

Prolem:  

getting an "IllegalStateException" when using the RequestDispatcher? 
1)java.lang.IllegalStateException: Header already sent 
2)java.lang.IllegalStateException: Cannot forward as Output Stream or Writer has already been obtained

Impact

Slows down your servlet communication, and at times can make your application behave intermittently.


Solution:


Make sure you only have one RequestDispatcher.forward("url") coded in your servlet and make sure it is always placed at the very end.


Also there is an interesting tip adapted from:


http://www.jguru.com/faq/view.jsp?EID=501393


Which states that:


If you want your response-writers to be modular (one object to build the nav bar, one object to build the banner ad, one object to build the body, one object to build the page footer, etc.), you have two choices:
  1. use JavaBeans or Java method calls to build up the HTML in the response, or
  2. use RequestDispatcher.include() to bring in content from many little servlets from inside a master response-builder servlet.


Tuesday, March 22, 2011

Key Learning Abdul Azeem Khan

Problem :
Target "compile-test-single" does not exist in the project "FileUploadExample". It is used from target "profile-test-single".

Impact:
In Netbeans you can no longer run any Enterpise, Web or Client application. A pretty serious issue

Solution:

The problem occurs when you accidentally hit a profiler button. To resolve the issue

Click on Profile > Attach Profiler > And Select External Application

Make sure to select External Application and no Internal Application