Follow in Twitter & Facebook


Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools



Monday, April 30, 2012

Excellent opening for dot net professionals - VOLVO IT

- No comments
Experience required for the Job: 4 - 6 years
Annual Salary of the Job: 0.0 - 10.0 Lacs
JOB DESCRIPTIONNOTE : We are looking for Permanent Employees

Developers : (.Net)Minimum 4 years of programming experience with excellent analytical, design, development skills to develop, enhance and maintain applications. He/she should
possess excellent written and verbal communication skills along with customer handling and stakeholder expectation management skills. Should have worked using
methodologies: Scrum / Agile, XP - Especially refactoring, Test Driven Development and configuration management

FlashBack Database and FlashBack Archive

- No comments
Introduction:
Here in this article,we will discuss about thease OracleDBA  concepts like FlashBack Database and FlashBack Archive.

Description:
FlashBack Database from Oracle 10g versions.This is also known as Rollbackward mechanism.

Where as coming to the restore and recovery are rollforward mechanism.

Flashback db is verymuch faster than Pointing time Recovery.

We have to set 2 parameters in the parameter file which are

Saturday, April 28, 2012

jQuery Hello World Sample

- No comments
jQuery is now very much popular client side technologies which is very leight weight and its basically nothing but  JavaScript library. You can develop very light weight component using jQuery. In this article we will see a Hello World program using jQuery. Also you can see this article for a basic jQuery tutorial.

Performance will be very faster, thats why now jQuery is very popular.

To write any jQuery code, we first need to call .js file like below:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

Then we need to write like normal JavaScript function like below:

<SCRIPT type=text/javascript>

jQuery(document).ready(function($) {

alert("Hello World !!!");
});

</SCRIPT>

You can also download Download ASP.NET jQuery Cookbook from here. You can also check how to enable Javascript in different Browsers.

Friday, April 27, 2012

Job Openings in Nous InfoSystems Bangalore

- No comments
Company name: Nous InfoSystems (CMMI® Level 5 v1.1 assessed, ISO 9001:2008 & ISO 27001:2005 certified global IT Company)
Software Engineer/Sr.Software Engineer (Microsoft)
Education: BE / B Tech / MCA / M.Sc
Experience: 3+ Years
Location: Bangalore

Skills:Strong programming skills in C#, ASP.NET and SQL

Cross-thread operation not valid:Control 'Level1' accessed from a thread other than the thread it was created on.

- No comments
Introduction:
Here we will discuss about one InvalidOperationException, which i got while doing one Windows application. The exception was like "Cross-thread operation not valid:Control 'lbl_Status' accessed from a thread other than the thread it was created on.". The error I got while working with BackgroundWorker.

Description:
I got this exception while doing one windows Application demo.I used there one progressbar control, one level,One BackgroundWorker and two buttons.
I want to see that progressing of the progressbar in terms of percentage.
In the line Me.lbl_Status.Text = FormatPercent(i/m_CountTo, 2)  , i got the error.

I use the same level for showing the status like Completed,Cancelled and to show that progess interms of percentage.
Why i got this error because we are using a background worker and we are attempting to acess controls on different thread .

Vb.Net doesn,t allow talking to objects on another thread directly, so have to go indirectly through one intermediate called Delegate.
A Delegate helps to communicate to objects of a different thread.
so i added the following lines of code:

 ' The delegate
    Delegate Sub SetLabelText_Delegate(ByVal [Label] As Label, ByVal [text] As String)
        Private Sub SetLabelText_ThreadSafe(ByVal [Label] As Label, ByVal [text] As String)
       
        If [Label].InvokeRequired Then
            Dim MyDelegate As New SetLabelText_Delegate(AddressOf SetLabelText_ThreadSafe)
            Me.Invoke(MyDelegate, New Object() {[Label], [text]})
        Else
            [Label].Text = [text]
        End If
      
    End Sub
And another changes i made one Substitute like Previously i wrote  Me.Lbl_Status.Text = FormatPercent(i / m_CountTo, 2)
Now i mentioned instead of that line the new line as belows:

SetLabelText_ThreadSafe(Me.lbl_Status, FormatPercent(i / m_CountTo, 2))
So now my code was errorfree, it worked fine.....

I am sharing the Screenshot as below....

Asp.NET with MVC Developer Walkin Tomorrow

- No comments
Experience: 3.5-5.5 yrs
Job Description:• Must have worked on 3.5/4.0
• Expertise with Framework 4.0 features including MVC Framework 2 or above and WCF 4.0
• Must have exposure to data modeling using Entity Framework or NHibernate or other ORM tool
• Knowledge on Windows Workflow Foundation 4.0. Required to have strong DB skills in either T-SQL or PL-SQL.

Java/J2EE Developer Walkin Tomorrow

- No comments
Experience: 3.5-5.5 yrs

Job Description:• Java, J2EE, JSP, Servlets, Spring Framework, Vignette Portlet Framework, Portlets(JSR), XML, Tomcat, JBOSS, Web Services
• Should have worked on at least 2 end to end application developments by using Java technology and should have good experience in web application development in Java
• Must be strong in Database

Informatica Developer Walkin Tomorrow

- 1 comment
Company Name: KPIT Cummins Infosystems Ltd.
Experience: 4-6 yrs
Location: Bangalore
Job Description:• Good hands on experience on Informatica 8.6 with design, development and testing experience.
• Documentation experience of database schema.
• Work Experience on Informatica 8.X and Oracle 10g.
• With at least 1 year on Informatica version 8.X.
• Experience on UNIX is a must.

Thursday, April 26, 2012

Creation of Virtual Machine :

- No comments
Introduction:
In this article we will discuss detail steps of how to create Virtual Machine (VMware).
  • VMware is virtual machine software which runs multiple operating systems on a single computer .
  • It’s an excellent testing and development platform.With the help of VMWARE we can create multiple operating system environments that can co-exist on the same computer in strong isolation from each other.
Steps to create VM ware team :
11.   Launch the VMware workstation. Click on New Virtual machine.

This BackgroundWorker states that it doesn't report progress.Modify WorkerReportsProgress to state that it does report progress.

- No comments
Introduction:
Here in this article, we will discuss about one InvalidOperationException which i got while doing one windows application demo using one BackgroundWorker using Vb.net. That Exception was like "This BackgroundWorker states that it doesn't report progress. Modify WorkerReportsProgress to state that it does report progress.".

Description:
I got this Exception while doing one demo in visual studio 2010 for one Backgroundworker in vb.net. I got the error like "This BackgroundWorker states that it doesn't report progress. Modify WorkerReportsProgress to state that it does report progress."

This is nothing but one InvalidOperationException.
At that time my code was like that only as belows

 Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        For i As Integer = 0 To m_CountTo
            ' Has the background worker be told to stop?
            If BackgroundWorker1.CancellationPending Then
                ' Set Cancel to True
                e.Cancel = True
                Exit For
            End If
            System.Threading.Thread.Sleep(1000) ' Sleep for 1 Second
            ' Report The progress of the Background Worker.
            BackgroundWorker1.ReportProgress(CInt((i / m_CountTo) * 100))
        Next
    End Sub



I got the exception in the line    BackgroundWorker1.ReportProgress(CInt((i / m_CountTo) * 100)).
I am sharing the screenshot of that exception as below:


So now i searched for the solution , I got the solution, the solution is that you need to set
the property  of the Backgroundworker i.e WorkerReportsProgess to true.Previously it was false. so i am also sharing the screenshot of that solution as below..

Wednesday, April 25, 2012

This BackgroundWorker is currently busy and cannot run multiple tasks concurrently.

- No comments
Introduction:
Here we will discuss about one InvalidOperationException, which I got while doing one demo using one BackgroundWorker control in case of a windows application by Vb.net. The Exception is like "This BackgroundWorker is currently busy and cannot run multiple tasks concurrently".

Description:
I got this InvalidOperationException, this Exception is like "This BackgroundWorker is currently busy and cannot run multiple tasks concurrently". I got this error when i was doing one demo in visual studio 2010 using that BackgroundWorker control in vb.net.

This is nothing but one InvalidOperationException. I got this one in the line BackgroundWorker1.RunWorkerAsync().
At that time my code looks like below

 Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load     
        BackgroundWorker1.RunWorkerAsync()
    End Sub
    Private Sub BackgroundWorker2_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
        System.Threading.Thread.Sleep(1000)
    End Sub

Then i am searching for the solution, I got the solution like we can check first wheather the BackgroundWorker is already busy or free by the help of IsBusy Property.
Now my code looks like as follows:

 Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not BackgroundWorker1.IsBusy Then
            BackgroundWorker1.RunWorkerAsync()
        Else
            MessageBox.Show("Can't run the worker twice!")
        End If
        BackgroundWorker1.RunWorkerAsync()
    End Sub
    Private Sub BackgroundWorker2_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
        System.Threading.Thread.Sleep(1000)
    End Sub

I am sharing the screenshot. It is as below..

Tuesday, April 24, 2012

Joins in SQL Server 2008

- No comments
Introduction:
Here we will discuss about different types of joins in SQL Server 2008. The joins are like Equi-joins, Non Equi-joins, Self-joins, Cartesian-joins, Outer joins. Also you can check my last article on Constraints in SQL Server 2008  and also you can check C#.Net Articles and Asp.Net Articles.

Description:
In order to retrive data from two or more tables based on logical relationship between the two tables, we require joins. Joins indicate how database should use data from one table to select the rows in another table.
There are different types of joins are there. These are like

Urgent Opening for Microsoft SharePoint Professionals

- No comments
We are the major service providers for leading IT and Non IT MNCs.We have many consultants working for us across the country with clients. In INDIA we have many offices . You can know more about us through our Website: http://www.anthroplace.com/
Also You can see more Jobs here.
This Requirement is for one of the Reputed IT Company
Experience required for the Job: 2 - 7 years
Annual Salary of the Job: 3.0 - 4.0 Lacs
Job Location: Kolkata
1)  Position - Microsoft SharePoint Professionals
Job Description:
We are looking for professionals who have experience in Microsoft-SharePoint Administration / Coding.

Error HRESULT E_FAIL has been returned from a call to a COM component.

- No comments
Introduction:
Here we will discuss about one error which i got while doing one Windows Forms application by Vb.Net. The error is like'Error HRESULT E_FAIL has been returned from a call to a COM component'.

Description:
I got this error "Error HRESULT E_FAIL has been returned from a call to a COM component" while doing just one demo windows application using Vb.Net.When i clicked the Form2.vb[design] tab in visual studio 2010, i got this error.At that time in that same project i had two forms, Form1 and Form2.

Monday, April 23, 2012

Different Editions of SQL Server 2008

- No comments
Introduction:
Here we will discuss different editions of SQL Server. Microsoft makes SQL Server avaible in different editions with different feature sets and targeting different users. Also you can check my last article on how to Change Authentication mode After installation of SQL Server. Visit Asp.Net, C#.Net, SQL Server and SharePoint articles more.

Description:
The different editions of Microsoft SQL Server are like SQL Server Compact Edition, SQL Server Developer Edition, SQL server 2005 Embedded Edition, SQL Server Enterprise Edition, SQL Server Evaluation Edition, SQL Server Express Edition, SQL Server Fast Track, SQL Server standard Edition,

Sunday, April 22, 2012

Difference between web application and web site in Asp.Net

- No comments
Introduction:
In this article we will discuss about What is the difference between a web application and web site in Asp.Net. Also you can check my last SQL Server article on Constraints in SQL Server 2008 and also you can check Strings and StringBuilder in C#.

Description:
Actually there is no hard and fast rule, wether you should go for Asp.Net web application and Asp.Net web site. But both have there advantages and disadvantages.

- Web Site project is compiled on the fly, so it compiles one or more dlls but web application complies the project into a single dll.

- But both supports IIS and the built-in ASP.NET Development Server.

- In case of web site each page has it's own assembly.

- If you really like single-page code model to code-behind model then you should go for web site.

- You can add an MVC application to a web application.

- If you want to migrate large Visual Studio .NET 2003 applications then web application is the option.

- If you want to add multiple web projects then Web application is the option.

Also you can follow more on this article
http://msdn.microsoft.com/en-us/library/aa730880(v=vs.80).aspx

http://blogs.msdn.com/b/aspnetue/archive/2009/12/14/asp-net-web-application-projects-vs-web-site-projects-in-visual-studio.aspx

Friday, April 20, 2012

Different Clauses in Sql Server 2008

- No comments
Introduction:
 Here we will discuss about different clauses in sqlserver like WHERE, GROUP BY, HAVING, ORDER BY etc. Also you can check my last article on Constraints in SQL Server 2008.

Description:
SQL Server provides with the following clauses that can be used in the Select statements like WHERE, GROUP BY, HAVING, ORDER BY.
The order while using inside a sql query is like
WHERE
GROUP BY
HAVING
ORDER BY

The complete syntax of the select statement looks as the following

Thursday, April 19, 2012

Constraints in SQL Server 2008

- No comments
Introduction:Here in this article, we will dicuss about different Constraints in SQL server.The Constraints are like Not Null, Unique, Primary key, Check, Default, Foreign Key. Also you can check my previous article on Delete and Truncate in sql server 2008.

Description:Constraints are used to enforce the integrity of the data in the columns, SQL Server 2005 provides the following mechanisim to enforce the data in the column.
-Not Null
-Unique
-Primary Key
-Check
-Default
-Foreign Key

Not Null:If it is applied to a column that column will not allow null values into it. This canbe imposed on any no of columns.

Wednesday, April 18, 2012

Difference between ToString() vs Convert.ToString() in C#.Net

- No comments
Here we will discuss what is the difference between ToString() vs Convert.ToString() in C#.Net. Also you can check my last article on Strings and StringBuilder in C# and Delete and Truncate in sql server 2008.

Very often we use ToString() and Convert.ToString() methods in C#.Net code. But it is important to know the difference between these two.

Convert.ToString() supports null whereas .ToString() will not support null. Means Convert.ToString() return string.Empty in case of null object but ToString() raise exception when the object is null.

So it is better to use Convert in C#.Net code always for good programming practice.

Also you can check Asp.Net cookies Advantages and disadvantages and a very good article on Delegates in C#.net.

Tuesday, April 17, 2012

Conversion from string "FalseFalse" to type 'Boolean' is not valid.

- No comments
Introduction:
Here we will discuss about one invalidcastException and its solution. The exception is 'Conversion from string "FalseFalse" to type 'Boolean' is not valid'. Also you can see some C#.Net Articles.

Description:
I don't know vb.net syntax. But for practicing purpose while doing one vb sample, i got the
exception like 'Conversion from string "FalseFalse" to type 'Boolean' is not valid'.
This is nothing but one invalidcastexception.At that time my code was like below

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        If txtUserName.Text.Length = 0 Then
            lblSubmit.Text = "UserName can't be blank"
        End If
        If CheckBox1.Checked = False & CheckBox2.Checked = False Then
            lblCheckbox.Text = "You should check atleast one"
      End If
    End Sub
After debuging my application, when i click on the button, i find this error.
Then i searched for the solution, finally i found that solution
The solution is i changed the '&' to 'And' so after that i didn't find that exception
Now my code looks like the below

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        If txtUserName.Text.Length = 0 Then
            lblSubmit.Text = "UserName can't be blank"
        End If
        If CheckBox1.Checked = False And CheckBox2.Checked = False Then
            lblCheckbox.Text = "You should check atleast one"
      End If
    End Sub
 I am sharing the screenshot of that exception . it is as below

Monday, April 16, 2012

Changing Authentication mode After installation of SQL Server:

- No comments
Introduction:
During installation, SQL Server database engine is set to either Windows Authentication mode
or SQL Server and Windows Authentication mode. Here we will discuss how to change the security mode after installation. You can also check my last article on Delete and Truncate in sql server 2008.

Description:
If Windows Authentication mode is selected during installation, the sa login remains disable.
If you later change authentication mode to SQL Server and Windows Authentication mode, the sa login remains disabled. To enable the sa login, use the Alter Login statement.

The sa login can only connect to the server by using SQL Server Authentication.

To Change security authentication mode:
In SQL Server Management studio Object Explorer, right click on the server, and then click Properties.
On the Security page, under the Server authentication, select the new server authentication mode, in the SQL Server Management studio dialog box, click ok to acknowledge the requirement to restart the  SQL Server.

To restart SQL Server from SQL Server Management studio:
In object explorer, right-click on your server, and then click Restart. If SQL Server Agent is running, it must also be restarted.

To Enable the sa login by using Transact-SQL:
Execute the statements to enable the sa password and assign a password.
Alter LOGIN sa Enable;
Alter Login sa WITH PASSWORD = '<enterstrongpassword>';

To Enable the sa loginby using Management Studio:
In Object Explorer, expand Security,expand Logins,right click sa, and then click Properties.
on the General page , you might have to create and confirm a password for the sa Login.
On the Status page, in the Login section, click Enabled, and then click ok.

Thursday, April 12, 2012

Strings and StringBuilder in C#

- No comments
Introduction:
Here in this article we will discuss about Strings and StringBuilder in C#.Net and what is the difference between String and StringBuilder in C#.Net. In the last article we have discussed about Delegates in C#.net.

Description:
Strings:
- In C#, a string is a built in and primitive data type. It maps to the System.String class. The objects of the string class or the string is are immutable by nature.

- Then the question is now what is the exact meaning of immutable by nature means, the state of the object cannot be changed by any operation. If we will take one example or casestudies then we can able to understand the meaning of immutable exactly.

Wednesday, April 11, 2012

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed

- No comments
Introduction:I got this runtime error while working with AJAX in asp.net. The error message is:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
Description:
I got this runtime error "Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException:
 The message received from the server could not be parsed." while doing one ajax operation in visualstudio 2010. You can also check the figure below.

What i exactly did is i placed one button inside the update panel within <ContentTemplate> </ContentTemplate>.
Then while debugging after clicking on the button i got the error.My code was like below.

Monday, April 9, 2012

Enable Javascript in different Browsers.

- No comments
Introduction:
Here in this article we will discuss how to enable JavaScript in different browsers like Firefox, IE and Opera. You can also check jQuery Hello World Sample.

Description:
Now a days we are using different browsers like internet explorer,Firefox and opera etc.
For doing some JavaScript operation the Javascript must be enabled in your browser. Without
enabling that option you cannot able to do any JavaScript operation. So here we will discuss
the path to enable the javascript in different browser.

For Internet Explorer 6/7:
step-1:
Open your browser click on the Tools option on the right top corner of your browser.

Friday, April 6, 2012

Wcf Implementation Example in VisualStudio 2010.

- No comments
Introduction:
Here we will see how the client will consume the WCFservice with a small example by visual studio 2010. You can check a very good article on how to create wcf and host wcf service in windows service in .Net.

Description:
First create a project by following path
File->New->Project->Then choose C# and click WCF tab in left side->Then Choose WCF Service Application. Then give project name as WcfSecondSample then click ok.

Now your project is created then it will create defaultly 3 files like service1.svc,IService1.cs and one web.config file. so if you want you can change the name of the interface (IService1.cs) and the classfile (Service1.svc). But for the timing i am not changing now.Let be the names as it is.
Then open the IService1.cs declare the method GetEmpDetails() and it will take a custom class object as a parameter.

I declared that custom class below to the Interface with [DataContract] attribute for that custom class and [Datamember] attribute for the inside members of the same custom class and i get and set the properties there .
The full code looks like belows

 [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetEmpDetails(Employee emp);
    }

    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class Employee
    {
        string EmpName = "";
        int  EmpID = 10;

        [DataMember]
        public string EmployeeName
        {
            get { return EmpName; }
            set { EmpName = value; }
        }
        [DataMember]
        public int EmployeeID
        {
            get { return EmpID; }
            set { EmpID = value; }
        }
    }



Then open that Service1.svc.cs,This is the implementation class for that interface.
Then write as belows.
  public class Service1 : IService1
    {
      public  string GetEmpDetails(Employee emp)
        {
            emp.EmployeeName = "Raju";
            emp.EmployeeID = 12;
            string output = "The emploee name and id is " +emp.EmployeeName+emp.EmployeeID;
            return output;
        }
       
    }
Now your coding for that wcf service is over then before handling this service to the client you need to test your service.You can test your service  by the help of WcfTestclient tool.
In order to test your service just open your visual studio 2010 command prompt thn go to the path like below

C:/Programfiles/visualstudio 10.0/Common7/IDE wcfTestclient http://localhost:50882/Service1.svc

Here  C:/Programfiles/visualstudio 10.0/Common7/IDE is the Path of wcfTestclient.
          http://localhost:50882/Service1.svc  is the Path of the service i.e right click on that service1.svc file then select view in browser and copy that path from url.
                                   
Then you can able to see your method and you can test the functionality by giving one value for Employeeid and name.

Then now your's Service is also ok so you can handle to the client now.so srevice work is over now we need to create a client so that that service can consume our service.
In order to create the client right click on the same solution ->Add New website ->Asp.net web Application then give the name as WCFSecondSampleClient then click ok.

Now your client is prepaired then this is the time to add the service reference.
For that right click on the client project in my case its WCFSecondSampleClient then select Add serviceReference then one window will open click discover button it will find the service then below to that one NameSpace option is there Change the name to any other name .In my case its MyProxy . Remember this name because its very important.Then click ok.
Then open the Default.aspx.cs and write in the page load like

 protected void Page_Load(object sender, EventArgs e)
    {
        MyProxy.Service1Client sobj = new MyProxy.Service1Client();
        MyProxy.Employee obj = new MyProxy.Employee();
        Response.Write(sobj.GetEmpDetails(obj));
     
    }
Here MyProxy is the Namespace name (That namespace name which we have given while adding that service reference).

Service1Client it will automatically come when you give that symbol dot(.) usually it will come as the name as your servicenameclient.

In second row Employee is the custom class that we have created in that IService1.cs.
You need to instanciate two times like this above. Then right click on client project (WCFSecondSampleClient in our case) and choose the option Set as startupProject.
Then now every thing done you can run the application and see the result. You can also check some WCF articles here.

Wednesday, April 4, 2012

Log4net.dll in Asp.Net

- No comments
Introduction:
In this post we will see what is Log4Net and how we can use Log4Net in asp.net. You can also visit this article which describes how you can use Log4Net in SharePoint.

Details:
Log4Net is really helpful in production environment where we can not debug our application (Because Visual Studio will not be available to us).
Also it happens sometimes that error will appear in the production server but don't appear in the development or testing server.
So by using Log4net , we can store or log or collect that errors which are going to happen at production time by giving some location there like in c drive by making one folder in that c drive.

After that you can able to get the error information from that location i.e that c drive with in that folder.Using Log4net , it will help you to collect errors in different ways like
  • File Appender (collect messages in file)
  • SMTP Appender  (collect messages in emails)
  • ADONet Appender (Collects messages in database)
  • EventLog Appender(collects messages in event viewer)
Using file appender helps you to print all messages you need in file. The file will be appended to rather than overwritten each time logging starts. There are different levels like:
  • Debug
  • Info
  • Warn
  • Error
  • Fatal
Here are the steps to use Log4Net:

Step-1:
Download the Log4net.dll from http://logging.apache.org/log4net/index.html

Step-2:
Then add reference that dll to your website by rightclicking on your website and choose Addreference. Its better you should make one dll folder and copy and paste the Log4net dll on dll folder and then add reference from that folder.

Step-3:
Make the following two changes in the web.config file.

1st change:
Put the code just after the configsection like
<configSection>
<Section name ="log4net" type = "log4net.Config.Log4netConfigurationSectionHandler,log4net"/>.


2nd change:
Put the below code after the end of System.web
</System.web>
<log4net>
<appender name = "LogFileAppender"
  type="log4net.Appender.FileAppender" Param =""
  value="C:\XXX\Log4netExample.log">
<layout type ="log4net.Layout.PatternLayout"
  Param="" name = "ConversionPattern"
  value="%d[%t]%-5p%c%m%n">
</layout>
</appender>
<root>
<level value="ALL">
<appender-ref ref = "LogfileAppender">
</appender-ref>
</level>
</root>
</log4net>

Step-4:
Write in the Global.asax
inside the Application_start
void Application_start(object sender,EverArgs e)
{
log4net.Config.DomConfiguration.Configure();
}

Step-5:
Now go to the .cs file where you trap the information like in my case Default.aspx.cs
Add below two namespaces

using log4net;
using log4net.Config;

Write the below code in side the class declaration, above the page_load

Ilog logger = log4net.LogManager.GetLogger(type of(_Default));

-Default is the class name
Ilog is the interface.

Then in side the pageload or button click where you want to trap the error can mention like below

logger.Info("This is info msgs");
 logger.Error("This is Error msgs");
logger.Warn("This is warn msgs");
logger.Fatal("This is Fatal msgs");
logger.Debug("This is Debug msgs");

After this open the path provided in the web.config in my case C:\XXX\Log4netExample.log file , you will find the error messages here.

For Example You can mention in the catch block while doing some try-catch operation in C#
Catch(Exception ex)
{
logger.Error("SelectByStoredProcedure:btnSubmit-click"+ ex.Message.Tostring());
}

Here SelectByStoredProcedure is the class name and btnSubmit-click is the submit button click event name.
If you mention all this class and all the details then you can able to know where the error occured and about the exact location details.

You can also visit this article for more information.

Tuesday, April 3, 2012

Checked and Unchecked operators in C#

- No comments
Introduction:
In this article we will discuss what are checked and unchecked operators in C#.Net. You can also see some C#.Net articles. Also you can check Static variables in C#.Net.

Description:
We all aware about Stack overflows or OverflowException was unhandled(Arithmetic operation resulted in an overflow).So while doing some arithmatic operation, we sometimes find this type of Exceptions. This is nothing but OverflowException.

Now the question is when exactly it comes ? Overflow happens when the range of a type is exceeded. When a value exceeds the limitations of a data type, it is said to overflow. So at this time these two operators come into the picture.

C# supports two types operators Checked and Unchecked, which can be used for checking and unchecking stack overflows during program execution.

Checked allows you to force C# to raise an exception whenever stack overflow (or underflow) occurs due to type conversion issues.

Unchecked will allow you to ignore these exceptions when the C# project is set to raise these types of exceptions.When using the default C# compiler options, arithmetic is unchecked.
This means that any overflowing data from arithmetic operations is simply truncated.
so finally if an operation is checked then an exception will be thrown if overflows occurs.
If it is not checked ,no exception will be raised but thing is that we will loose the data.

Example:
int a = 200000 ;
int b = 300000 ;
try
{
int m = checked(a*b) ;
}
catch(OverflowException e)
{
console.writeline(e);
}
since a*b produced a value that will easily exceed the maximum value for an int , an overflow occurs .An overflow exception thrown like this . we will get the output as
System.OverflowException : An exception of type System.OverflowException was thrown at ........

If you want to suppress that overflow hecking , we can mark the code as unchecked .

int a = 200000 ;
int b = 300000 ;
try
{
int m = Unchecked(a*b) ;
}
In this case no exception will raise but we will loose the data. Also check Dataset and Datareader asp.net.