473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Handle exception thrown by system.

For no apparent reason, a NullReference exception is thrown in
system.dll
(System.Net.Sockets.OverlappedAsyncResult.Completi onPortCallback).
Since I only get a disassembly from Visual Studio, it is almost
impossible to figure out what causes this. I've tried adding:

AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler (SystemErrorHandler);

to my main method, and a handler function:

static void SystemErrorHandler(Object Sender,
UnhandledExceptionEventArgs Args)
{
Exception e = (Exception)Args.ExceptionObject;
Console.WriteLine ("Caught : " + e.Message);
}

But the handler never gets invoked. The exception just causes the
program to halt.

I think I've narrowed the cause down to some file-downloading done in
the program. I've tried both a WebClient.DownloadFile(), and a more
lowlevel WebRequest method, but they both causes this error.

Please help me find a way to, if not eliminate, at least contain the
exception.

Nov 15 '05 #1
5 4004
Vitling,

Can you show an example or give details on how to reproduce the error?
Without knowing that, it is very difficult to know what you are doing.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vitling" <mrboo@ht_u.se> wrote in message
news:3f****************@news.microsoft.com...
For no apparent reason, a NullReference exception is thrown in
system.dll
(System.Net.Sockets.OverlappedAsyncResult.Completi onPortCallback).
Since I only get a disassembly from Visual Studio, it is almost
impossible to figure out what causes this. I've tried adding:

AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler (SystemErrorHandler);

to my main method, and a handler function:

static void SystemErrorHandler(Object Sender,
UnhandledExceptionEventArgs Args)
{
Exception e = (Exception)Args.ExceptionObject;
Console.WriteLine ("Caught : " + e.Message);
}

But the handler never gets invoked. The exception just causes the
program to halt.

I think I've narrowed the cause down to some file-downloading done in
the program. I've tried both a WebClient.DownloadFile(), and a more
lowlevel WebRequest method, but they both causes this error.

Please help me find a way to, if not eliminate, at least contain the
exception.

Nov 15 '05 #2
I'm sorry but I can't isolate any specific component other then just
file downloading. This is done by simply using

Webclient.DownloadFile(URL,LocalPath)

This works for the most part, but then, every once in a while, the
error occurs. It can appear at almost any time during execution, even
when no file is currently beeing downloaded. But yet, if I disable the
download function the error disappears. It almost seems like this is
the result of some download-cleanup background system task failing. Im
not doing any network-related c# coding, just using the webclient
object.

Another wierd thing is that I can't seem to find any reference to
CompletionPortCallback in the source for OverlappedAsyncResult:

http://dotnet.di.unipi.it/Content/ss...cs-source.html

I've only been able to reproduce this error by running the entire
application and, im afraid, Im not allowed to post it here.
The application downloads, and processes documents using URLs gathered
from a search process. The files downloaded is therefore not the same,
every time the program runs. I've not been able to detect any
correlation between URLs and errors. Perhaps it is caused by invalid
data send by some webserver, but since it seems to be related to an
"old" network access. (error can occur even when no d.l. is
happening), I cant find any way to debug it.

I know that this is a debugging nightmare, but If there's at least a
way to discard the execption and avoid the program halt, I would be
very happy.

Thanks,
Danie


On Mon, 8 Dec 2003 09:00:55 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Vitling,

Can you show an example or give details on how to reproduce the error?
Without knowing that, it is very difficult to know what you are doing.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vitling" <mrboo@ht_u.se> wrote in message
news:3f****************@news.microsoft.com...
For no apparent reason, a NullReference exception is thrown in
system.dll
(System.Net.Sockets.OverlappedAsyncResult.Completi onPortCallback).
Since I only get a disassembly from Visual Studio, it is almost
impossible to figure out what causes this. I've tried adding:

AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler (SystemErrorHandler);

to my main method, and a handler function:

static void SystemErrorHandler(Object Sender,
UnhandledExceptionEventArgs Args)
{
Exception e = (Exception)Args.ExceptionObject;
Console.WriteLine ("Caught : " + e.Message);
}

But the handler never gets invoked. The exception just causes the
program to halt.

I think I've narrowed the cause down to some file-downloading done in
the program. I've tried both a WebClient.DownloadFile(), and a more
lowlevel WebRequest method, but they both causes this error.

Please help me find a way to, if not eliminate, at least contain the
exception.



Nov 15 '05 #3
On Mon, 08 Dec 2003 17:48:54 GMT, mrboo@ht_u.se (Vitling) wrote:
<snip>

http://dotnet.di.unipi.it/Content/ss...cs-source.html


The source code is:

private static void CompletionPortCallback(uint errorCode, uint
numBytes, NativeOverlapped* nativeOverlapped)
{
Overlapped overlapped1;
OverlappedAsyncResult result1;
bool flag1;
overlapped1 = Overlapped.Unpack(nativeOverlapped);
result1 = ((OverlappedAsyncResult) overlapped1.AsyncResult);
if (errorCode != 0)
{
flag1 = OSSOCK.WSAGetOverlappedResult(((Socket)
result1.AsyncObject).Handle, ((IntPtr)
nativeOverlapped), &(numBytes), 0,
IntPtr.Zero);
errorCode = OSSOCK.WSAGetLastError();
}
result1.ReleaseUnmanagedStructures();
result1.ErrorCode = errorCode;
result1.InvokeCallback(0, numBytes);
}
I got this by using Reflector: http://www.aisto.com/roeder/dotnet/
and it's under System.dll System.Net.Sockets.OverlappedAsyncResult

This is obviously a change from the 1.0 framework. Perhaps you could
target 1.0 and see if the error still occurs.

Austin Ehlers

<snip>
Nov 15 '05 #4
Is there really no way to discard the exception and continue
execution. Now the program just dies :(

On Mon, 08 Dec 2003 16:51:01 -0600, Austin Ehlers
<th***********************@hotmail.com> wrote:
On Mon, 08 Dec 2003 17:48:54 GMT, mrboo@ht_u.se (Vitling) wrote:
<snip>

http://dotnet.di.unipi.it/Content/ss...cs-source.html


The source code is:

private static void CompletionPortCallback(uint errorCode, uint
numBytes, NativeOverlapped* nativeOverlapped)
{
Overlapped overlapped1;
OverlappedAsyncResult result1;
bool flag1;
overlapped1 = Overlapped.Unpack(nativeOverlapped);
result1 = ((OverlappedAsyncResult) overlapped1.AsyncResult);
if (errorCode != 0)
{
flag1 = OSSOCK.WSAGetOverlappedResult(((Socket)
result1.AsyncObject).Handle, ((IntPtr)
nativeOverlapped), &(numBytes), 0,
IntPtr.Zero);
errorCode = OSSOCK.WSAGetLastError();
}
result1.ReleaseUnmanagedStructures();
result1.ErrorCode = errorCode;
result1.InvokeCallback(0, numBytes);
}
I got this by using Reflector: http://www.aisto.com/roeder/dotnet/
and it's under System.dll System.Net.Sockets.OverlappedAsyncResult

This is obviously a change from the 1.0 framework. Perhaps you could
target 1.0 and see if the error still occurs.

Austin Ehlers

<snip>


Nov 15 '05 #5
I've managed to get some info from the debugger. Sorry for the poor
formatting:

- $exception {"Object reference not set to an instance of
an object." } System.NullReferenceException
- System.SystemException {"Object reference not set to an
instance of an object."} System.SystemException
- System.Exception {"Object reference not set to an
instance of an object." } System.Exception
System.Object {System.NullReferenceException} System.Object
_className null string
_COMPlusExceptionCode -532459699 int
_exceptionMethod <undefined value>
System.Reflection.MethodBase
_exceptionMethodString null string
_helpURL null string
_HResult -2147467261 int
_innerException { } System.Exception
_message "Object reference not set to an instance of an
object." string
_remoteStackIndex 0 int
_remoteStackTraceString null string
_source null string
- _stackTrace {System.Array} System.Object
[0] 0 sbyte
[1] 0 sbyte
[2] 0 sbyte
[3] 0 sbyte
[4] 0 sbyte
[5] 0 sbyte
[6] 0 sbyte
[7] 0 sbyte
[8] 40 sbyte
[9] -92 sbyte
[10] -4 sbyte
[11] 6 sbyte
[12] 79 sbyte
[13] -84 sbyte
[14] -19 sbyte
[15] 6 sbyte
[16] -96 sbyte
[17] -4 sbyte
[18] 54 sbyte
[19] 11 sbyte
[20] -40 sbyte
[21] -96 sbyte
[22] -3 sbyte
[23] 6 sbyte
_stackTraceString null string
_xcode -1073741819 int
_xptrs 188151788 int
HelpLink null string
HResult -2147467261 int
InnerException { } System.Exception
Message "Object reference not set to an instance of an
object." string
Source "System" string
StackTrace " at
System.Net.OSSOCK.WSAGetOverlappedResult(IntPtr socketHandle, IntPtr
overlapped, UInt32& bytesTransferred, Boolean wait, IntPtr
ignored)\r\n at
System.Net.Sockets.OverlappedAsyncResult.Completio nPortCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)"
string
+ TargetSite {System.Reflection.RuntimeMethodInfo}
System.Reflection.MethodBase
errorCode 64 uint
numBytes 0 uint
- nativeOverlapped 1773720
System.Threading.NativeOverlapped*
- System.ValueType {System.Threading.NativeOverlapped}
System.ValueType
System.Object {System.Threading.NativeOverlapped}
System.Object
EventHandle 0 int
InternalHigh 0 int
InternalLow -1073741299 int
OffsetHigh 0 int
OffsetLow 10054 int
- ReservedClasslib
{System.Runtime.InteropServices.GCHandle}
System.Runtime.InteropServices.GCHandle
- System.ValueType
{System.Runtime.InteropServices.GCHandle} System.ValueType
System.Object <undefined value> System.Object
__InternalTarget
{System.Net.Sockets.OverlappedAsyncResult} System.Object
IsAllocated error: cannot obtain value bool
m_handle <has no runtime value> int
Target error: cannot obtain value System.Object
ReservedCOR1 1 int
- ReservedCOR2 {System.Runtime.InteropServices.GCHandle}
System.Runtime.InteropServices.GCHandle
- System.ValueType
{System.Runtime.InteropServices.GCHandle} System.ValueType
System.Object <undefined value> System.Object
__InternalTarget
{System.Threading.IOCompletionCallback} System.Object
IsAllocated error: cannot obtain value bool
m_handle <has no runtime value> int
Target error: cannot obtain value System.Object
ReservedCOR3 1904976 int
On Mon, 8 Dec 2003 09:00:55 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Vitling,

Can you show an example or give details on how to reproduce the error?
Without knowing that, it is very difficult to know what you are doing.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vitling" <mrboo@ht_u.se> wrote in message
news:3f****************@news.microsoft.com...
For no apparent reason, a NullReference exception is thrown in
system.dll
(System.Net.Sockets.OverlappedAsyncResult.Completi onPortCallback).
Since I only get a disassembly from Visual Studio, it is almost
impossible to figure out what causes this. I've tried adding:

AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler (SystemErrorHandler);

to my main method, and a handler function:

static void SystemErrorHandler(Object Sender,
UnhandledExceptionEventArgs Args)
{
Exception e = (Exception)Args.ExceptionObject;
Console.WriteLine ("Caught : " + e.Message);
}

But the handler never gets invoked. The exception just causes the
program to halt.

I think I've narrowed the cause down to some file-downloading done in
the program. I've tried both a WebClient.DownloadFile(), and a more
lowlevel WebRequest method, but they both causes this error.

Please help me find a way to, if not eliminate, at least contain the
exception.



Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: cody | last post by:
public DateTime Value { get { try { return new DateTime(int.Parse(tbYear.Text), int.Parse(tbMonth.Text), int.Parse(tbDay.Text)); } catch (FormatException)
4
by: Bhavya Shah | last post by:
Hello, I am facing a very strange problem in my application. I have a form on which I select a path. I open the FolderBrowserDialog for path selection. Once the path is selected I press a button...
17
by: ahaupt | last post by:
Hi all, I'm currently writing a load of class libraries, but not the main application iteslf. I want to provide some method for reporting errors back to the main application. At the moment...
2
by: Nick Gilbert | last post by:
Hi I have a number of pages where it is valid for the user to enter HTML. On these pages, I have turned off RequestValidation ("ValidateRequest = false" in the page directive) so that the...
19
by: Diego F. | last post by:
I think I'll never come across that error. It happens when running code from a DLL that tries to write to disk. I added permissions in the project folder, the wwwroot and in IIS to NETWORK_SERVICE...
1
by: matt.arens | last post by:
here is some background: I am using the MQSeries/Websphere .Net classes provided by Microsoft. The Websphere Windows Client software is required in order to use the ..Net classes. However, I...
6
by: Liming | last post by:
Hi, In a typical 3 tier model (view layer, busines layer and data access layer) where do you handle your exceptions? do you let it buble up all the way to the .aspx pages or do you handle it in...
10
by: tcomer | last post by:
Hello! I've run into a problem and I can't seem to understand "why" the problem occurs. In my program: using System; using System.IO; using System.Xml; namespace MyNamespace { class MainApp
9
by: =?Utf-8?B?UmFq?= | last post by:
How do I know which methods will throw exception when I am using FCL or other third party .Net library? I am developer of mostly native Windows applications and now .Net. After working few...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.