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

Top 5 Contributors of the Month
Melody Anderson
Post New Web Links

SystemNetworkInterface.GetAdaptersAddresses throw exception

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :.NET Framework


I got this exception:

Exception: System.Net.NetworkInformation.NetworkInformationException
Message: The handle is invalid

when the function SystemNetworkInterface.GetAdaptersAddresses is call the first time.

Call stack:

Source: System
   at System.Net.NetworkInformation.SystemNetworkInterface.GetAdaptersAddresses(AddressFamily family, FixedInfo fixedInfo)
   at System.Net.NetworkInformation.SystemNetworkInterface.PostWin2KGetNetworkInterfaces(AddressFamily family)
   at System.Net.NetworkInformation.SystemNetworkInterface.GetNetworkInterfaces(AddressFamily family)
   at System.Net.NetworkInformation.SystemNetworkInterface.InternalGetIsNetworkAvailable()
   at System.Net.NetworkInformation.NetworkChange.AvailabilityChangeListener.ChangedAddress(Object sender, EventArgs eventArgs)
   at System.Net.NetworkInformation.NetworkChange.AddressChangeListener.AddressChangedCallback(Object stateObject, Boolean signaled)
   at System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)

I'm using c# 3.5. The problem occurs on Windows 2008. Not on windows XP.

The network card is: Intel PRO 1000 MT Quad Port NIC.

How could I know the reason why the

View Complete Post

More Related Resource Links

Creating database throw exception!

When running SQL commands, it throws error information. Why is it? My env :    windows server 2003 64bit     sql server 2008 . Command :   CREATE DATABASE [AdventureWorks2009]     ON (NAME = 'AdventureWorks2009_Data', FILENAME = N'E:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWorks2009_Data.mdf', SIZE = 170, FILEGROWTH = 8),     FILEGROUP DocumentFileStreamGroup CONTAINS FILESTREAM ( NAME = FileStreamDocuments, FILENAME = N'E:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Documents')     LOG ON (NAME = 'AdventureWorks2009_Log', FILENAME = N'E:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWorks2009_Log.ldf' , SIZE = 2, FILEGROWTH = 96); GO     Error information:   Msg 5120, Level 16, State 106, Line 1 Unable to open the physical file "E:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Documents". perating system error -2147024891: "0x80070005(failed to retrieve text for this error. Reason: 1815)".

throw exception message giving internal server error on live site


using vb.net/asp.net 2005

when a user enters a bad email I am doing a check on this and throwing an exception message as follows, this works fine on the test site but for some reason the same code on the live site gives a "internal server error" (http code 500).  The code below:

            If isThisEmailValid(strEmailThatTheUserEntered) Then
		'do something


                Throw New Exception("You entered a bad email address.")

            End If

not certain why this is happening, I assume that it's some server or config difference between the test and live sites.  has anyone seen this before?  For a quick fix i'm registering javascript alert and showing the same text so it works but I would like to figure out why the code above is not working.

as always, thanks for your feedback


JDBC - How can I get it to not throw an exception on ResultSet.isLast()?


Is there some way to configure the Sql Server JDBC driver, or parameters on the Connection or prepareStatement() so that ResultSet.isLast() can be called when I call a stored procedure that returns a ResultSet?

thanks - dave

Very funny video - What's your Metaphor?

When processing files recursively, why the top DirectoryInfo always throw a Exception?



I have quite a simple app, which modify the CreationTime property of all the subfiles and subfolders in a folder, the code is like:

    void Mod(DirectoryInfo dir, DateTime time)
      foreach (DirectoryInfo subDir in dir.GetDirectories())
        Mod(subDir, time);
      foreach (FileInfo fi in dir.GetFiles())
        fi.CreationTime = time;
      dir.CreationTime = time;

I call this method with a folder like: C:\a\b, then all the subfiles and subfolders are correctly modified, but WHY I received an Exception: The process cannot access the file 'C:\a\b' because it is being used by another process.

I changed the folder to: C:\a, then C:\a\b was modified successfully, then I got an Exception:The process cannot access the file 'C:\a' because it is being used by another process.

thanks in advance.

throw and catch exception handling



iam inserting record in three tables in a database, iam using begin trans , commit transaction and rollback,

i want to use throw method, if  any value insert wrong, pls correct me, i want to throw the error and

its go to rollback

running = false;
                        int updaterec = DBmgr.ExecuteNonQuery(CommandType.Text, "update ASArrivedcontainer set billgen ='Y' where billgen ='y' and acontinerid in ("+SelValues+")");
                        if (updaterec > 0)
                            running = true;
                            DataSet BillContainerDetails = BillingDetails();

EntityDataSource throw Exception when Update with Self-Reference


For a Table A defined in the DB like this:

A : { id, selfId, name, ... }

where selfId is a foreign key refered to Table A itself.

I generated the Entity automatically like this:

A : { string id; A self; string name, ... }

when i update the entity in gridview Edit/Update CommandField

i got the exception:

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: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be

Can a timer be used to throw a timeout exception in a WCF operation?


I am developing a webservice for a third party to talk with and they have a requirement of the process running at max 15 seconds.  If the webservice is taking longer than that, then a specific XML reply must be sent back to them to notify that the service is taking too long.

I have tried to do this by encapsulating the 'meat' of the operation in a Try/Catch statement.  Inside the Try portion I create a private scoped System.Timers.Timer with an interval of 15000.  I have a Catch statement that is looking for a TimeoutException which will create the appropriate file when the exception occurs.  There is also an ending Catch statement that just catches any exception and creates another file in that instance.

After I create the timer, I have tried setting Enable to True, setting Enable to True + calling the Start method, and calling the Start method.   After the timer creation/enabling, I am calling a System.Threading.Thread.Sleep(20000).  I have a private shared delegate Sub that is fired when the Timer.OnElapsed event fires.  This Sub has a simple Throw TimeoutException('Timeout Exception Occured!') call in it.

I have tested this each way and none of them seem to actually fire the event on the timer.  The thread sleeps for 20 seconds and then continues on and the service continues on without issue as


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:

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.


{ End Bracket }: Don't Be Afraid To Throw Away Your Work


With today's processing power at your disposal, Josh Phillips recommends speculative computation-performing operations ahead of time even if you may never need the results.

Josh Phillips

MSDN Magazine October 2008

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