.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

.NET Matters: Const in C#, Exception Filters, IWin32Window, and More

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Welcome to . NET Matters. This new column will delve into the ins and outs of the Microsoft® . NET Framework, answering readers' questions on various topics related to its extensive libraries, languages, and the common language runtime.

Stephen Toub

MSDN Magazine April 2004

View Complete Post

More Related Resource Links


Every self-respected programmer should include exception handling techniques. Sometimes your application will generate an error. Regardless of who was responsible for this error, the programmer or the user, it is up to the first to include the necessary exception handling techniques to keep his/her program from crashing. The .Net environment provides useful techniques for avoiding disastrous errors such as try-catch statements and user-defined exceptions.

Global Exception Handling with ASP.NET

After your global exception handler has done its work, you'll want to redirect the users of your website to a friendly page that tells them that something has gone wrong, and then provide them with customer support information as well as a link back to your web application's home page.

SQL Server 2005 Try and Catch Exception Handling

I'm pretty excited to see that there is some real error handling for T-SQL code in SQL Server 2005. It's pretty painful to have your wonderfully architected .NET solution tainted by less-than-VBScript error handling for stored procedures in the database. The big difference being the addition of TRY..CATCH blocks. Let's take a look:

jQuery 1.4 Opacity and IE Filters

client side jQuery library after switching to jQuery 1.4. I ran into a problem with a shadow plugin that I use to provide drop shadows for absolute elements - for Mozilla WebKit browsers the -moz-box-shadow and -webkit-box-shadow CSS attributes are used but for IE

Customizing the UI around the Filters


I have started working on a new project and thought it would be a great idea to dig into the latest version of the Dynamic Data framework that shipped with VS2010.  For the most part, I am impressed, it seems to be pretty easy to extend and create a rich and flexibile UI -- at least that is what I thought until I got to working on a better layout for the filters.

The situation is this:

I have a table with 25 columns and I need to display around 10 different filters (basically and interactive report) -- the filters are of various types.

The problem:

How in the world do I custom the UI layout of the filters.  It seems that with the latest QueryFilterRepeater control we have been left with almost nothing to work with (outside of turning filters on/off and setting the FilterUIHint).  What if I wanted to wrap all of the filters in an expand/collapse region and then inside of that have then sitting in a table of no more than 4 columns (so with 10 filters I wold have 3 rows). 

I have tried extending the QueryFilterRepeater but it seems like there is nothing in that class that we can work with (the data binding events are not even used).

Am I missing something, or am I just out of luck right now?

Customising filters in .NET 4


I have a .NET 3.5 Dynamic Data site that I am now overhauling to make it work under .NET 4.  I have managed most of it now (painfully!) but am struggling to get my old custom filters to work.

Under .NET 3.5, the default filter mark-up looked like this:

<asp:FilterRepeater ID="FilterRepeater" runat="server">
        <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" />
        <asp:DynamicFilter runat="server" ID="DynamicFilter" OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />
    <FooterTemplate><br /><br /></FooterTemplate>
This code shows all possible filters above the table; i.e., every column in the table containing a foreign key to another table.  I didn't want to see them all, just the one I was interested in, so previously I had this mark-up in my ListDetails.aspx file:

<asp:Label runat="server" Text="Panel" AssociatedControlID="DynamicFilterPanel$DropDownList1" style="padding-left: 20px;" />
<asp:DynamicFilter runat="server" ID="

reader.getordinal("column_may_not_exist") how to catch the exception?



would any body please help me to catch the exception if the column doesnot exist as my table columns are not static.

sometimes its throwing me indexoutofrange exception as the column doesnot exist

thanks for the help guys

Error while using exception handling block el 4.1


Hi Folks,


i am trying to use tyhe exception handling block of Enterprise library 4.1.


I just createda polisy and used IndexOutOfRangeException and added a replace handler and a logging handler to it.

I am using the NotifyRethrow PostHandlingAction to the exception.


During runtime I am getting an exception on the HandleException event, The exception is added below:



Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 42:             catch (Exception ex)
Line 43:             {
Line 44:                 bool reThrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy");
Line 45:         

userprincipal.changepassword throws exception


Hi all,

      userprincipal.changepassword(oldpassword, newpassword);

gives error: that is Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. (Exception from HRESULT: 0x80070547)

but userDirectoryEntry.invoke("ChangePassword", new object[] { oldpassword, newpassword });

      userDirectoryEntry.CommitChanges works fine.

Any one please tell me the reason behind this.

active directory exception unusual behaviour


i have a small problem
i want user names from active directory for an auto completer type of service
the method is always throwing an exception 
"searcher.FindAll()' threw an exception of type 'System.DirectoryServices.DirectoryServicesCOMException' System.DirectoryServices.SearchResultCollection 

"Exception from HRESULT: 0x800AC472"


Am Exporting Data in to Excel File,meanwhile if i open any other Excel file than the excel File on which am exporting data gets opened up Automatically having name Book1.How should i stop these excel file not to get open.In the Error log i get an error message showing " Exception from HRESULT: 0x800AC472" . Need help on these.Thanks in Advance.

WebControls.TableRow throws exception on Add()


I have the following method to strip hidden and user-specified columns from a gridviewrow and return a tablerow. 

    Private Shared Function StripHiddenColumns(ByVal gvRow As GridViewRow, ByVal ColumnsToExclude() As Integer) As TableRow

        Dim row As New TableRow
        Dim i As Integer = 0
            For Each cell As TableCell In gvRow.Cells
                If cell.Visible Then
                    If Not ColumnsToExclude.Contains(i) Then
                    End If
                End If
                i += 1

            Return row
        Catch ex As Exception
            Throw ex
        End Try
    End Function

However, when I run this code and hit the Add method for the TableRow,  I get an InvalidOperationException stating the Collection was modified; enumeration operation may not execute.  I've gotten this exception before, but usually it's because I'm attempting to modify a table that is databound.  This particular one is not, i am creating it.  Can anyone offer any insight? 

Thanks in advance.


Assigning a value to const int



I have a const int varable to which i need to assing a value from config value .When I  was giving it as

public const int MaxValue = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["MaxVal"].ToString());;

I was getting a error .Can anyone help me out

.NET Matters: Aggregating Exceptions


Exceptions in .NET are the fundamental mechanism by which errors and other exceptional conditions are communicated. This month's column provides information about how to aggregate exceptions to help manage a variety of scenarios in which multiple exceptions might result from one operation, including scenarios involving parallelism and concurrency.

Stephen Toub

MSDN Magazine August 2009

.NET Matters: Parallelizing Operations With Dependencies


In this month's installment, Stephen Toub examines some techniques for enforcing dependencies in the running order of asynchronous operations and builds a DependencyManagement class to help.

Stephen Toub

MSDN Magazine April 2009

.NET Matters: Ordered Execution With ThreadPool


This month we demonstrate how you can use the ThreadPool to support ordered execution without having to build custom thread pools yourself.

Stephen Toub

MSDN Magazine February 2009

Net Matters: Round-Robin Access To The ThreadPool


Stephen Toub shows you how to add round-robin scheduling support on top of the ThreadPool for more granular processing control.

Stephen Toub

MSDN Magazine January 2009

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend