.NET Questions and Solutions

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for the ‘exception’ Category

Client computers cannot download attachments when you use ISA Server 2004 or ISA Server 2006 forms-based authentication and run a third-party OWA add-in program to manage attachments

Symptoms
Consider the following scenario: You use forms-based authentication in Microsoft Internet Security and Acceleration (ISA) Server 2004 or ISA Server 2006 to publish a Microsoft Outlook Web Access (OWA) server. You use a third-party OWA add-in program to manage e-mail attachments.In this scenario, when client computers use OWA and download e-mail attachments, the computers cannot download attachments.Additionally,you may receive an error message that resembles the following:

Internet Explorer cannot download file from server.
Internet Explorer was not able to open this Internet site. The requested site is
either unavailable or cannot be found. Please try again later.
Resolution
This problem occurs because the ISA Server 2004 or ISA Server 2006 forms-based authentication filter adds a Cache-Control: no-cache header to all responses for Active Server Pages (ASP) page requests except for known requests that are used by OWA for attachment downloads. The Cache-Control: no-cache header is added to ASP page requests to avoid session problems that occur with some non-Microsoft browsers.
When you use a third-party OWA add-in program that uses ASP pages for attachment downloads, the Cache-Control: no-cache header that is added to the ASP page response prevents Windows Internet Explorer from caching the attached file. Therefore, Internet Explorer cannot download or open the file. For more information about this problem, click the following article number to view the article in the Microsoft Knowledge Base:
316431?(http://support.microsoft.com/kb/316431/) Internet Explorer is unable to open Office documents from an SSL Web site

BUG: You receive an “Unhandled Win32 exception” error message you use the Just-In-Time (JIT) debugger

Symptoms
When you use the Just-In-Time (JIT) debugger, you may experience the following symptoms: You receive the following error message:

“Just -In-Time Debugging Handler and CLR Remote Host: An exception ‘unhandled win32 exception’ has occurred in process ‘processID’. However, Visual Studio 7 just-in-time debugging has failed. Would you like to try debugging with the previously registered debugger (msdev path/msdev.exe)?”You receive an error message and the JIT Debugger does not start.
Resolution
This problem is because the absolute path of the shell resides in the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\shell with a value c:\windows\explorer.exe or c:\winnt\explorer.exe.

BUG: You receive an “EXCEPTION_ACCESS_VIOLATION” error message when you use a RIGHT OUTER JOIN clause in SQL Server 2000

Symptoms
In Microsoft SQL Server 2000, when you run a query that contains a RIGHT OUTER JOIN clause, you may receive an error message that is similar to the following:

ODBC: Msg 0, Level 19, State 1
SqlDumpExceptionHandler: Process 52 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
Connection Broken
Resolution
Service pack informationTo resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
290211?(http://support.microsoft.com/kb/290211/) How to obtain the latest SQL Server 2000 service pack

BUG: You receive a run-time exception error message when you run the debug build of your application with the /RTCs compiler option enabled

Symptoms
When you run the debug build of your application with the /RTCs compiler option enabled,you may receive the following exception error message:

Run-Time Check Failure #0 – The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.You receive this error message when the following conditions are true:You call a function that does not use the__cdecl modifier.The function contains parameters that are larger than 64 kilobytes (KB).You compile your applicationin the Debug mode and with the /RTCs compiler option enabled.
Resolution
When you pass a parameter that is 64 KB or larger to a function that does not use the __cdecl modifier,the compiler generates incorrect code. When the function that is called tries to return control to the calling function, the compiler triggers the error that is mentioned in the “Symptoms” section. The compiler generates a 16-bit immediate return (RET) that has an operand that is limited to 64 KB. If the parameters that are passed to the function are larger than 64 KB,the stack becomes corrupted when the function returns.

BUG: You receive a security exception error message when you call the EventLog.WriteEntry method by using the EventLogPermissionAccess.Write access level in the .NET Framework 2.0

Symptoms
Consider the following scenario. In the Microsoft .NET Framework 2.0, you create an instance of the EventLogPermission class that has the EventLogPermissionAccess.Write access level. You call the EventLogPermission.PermitOnly method to restrict code access. Then you call the EventLog.WriteEntry method to write an entry to the event log. In this scenario,you receive a security exception error message that resembles the following:

Unhandled Exception: System.Security.SecurityException: Request for the permission of type ‘System.Diagnostics.EventLogPermission, …’ failed.
Resolution
To work around this issue, you must request the EventLogPermissionAccess.Administer access level before you call the EventLogPermission.PermitOnly method. After you specify this access level, you can call the EventLog.WriteEntry method and write an entry to the event log. The following code example demonstrates how to write an entry to the event log by using this workaround.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

using System;using System.Diagnostics;public class TestCase{ public static void Main() { EventLogPermission eventLogPermission = new EventLogPermission(EventLogPermissionAccess.Administer, “.”); eventLogPermission.PermitOnly(); EventLog.WriteEntry(“Source”, “Message”); }}

BUG: You receive a COMException exception when you pass late-bound parameters to methods of Office objects in Visual Basic 2005 or in Visual Basic .NET

Symptoms
In a Microsoft Visual Basic 2005 or Microsoft Visual Basic .NET application, when you pass late-bound parameters to methods of Microsoft Office objects, you may receive COMException exceptions. For example, when you pass the Name property of a late-bound UserProperty object to the UserProperties.Items method, you may receive the following error message:

An unhandled exception of type ‘System.Runtime.InteropServices.COMException’ occurred in microsoft.visualbasic.dll
Additional information: Property is read-only.Note Similar symptoms may also occur when you call methods of other Microsoft Office objects.
Resolution
If you pass a property of an object to a method by reference and the property has a set accessor, Visual Basic calls the set accessor to set the property to the value that the method returns. At compile time, if you pass a property of a late-bound object, the Visual Basic compiler cannot determine whether the property is passed by reference. Also, the Visual Basic compiler cannot determine whether the property has a set accessor. Therefore, the Visual Basic compiler permits the late binder to determine these details at run time.
However, if the relevant objects are Component Object Model (COM) objects at run time, the late binder cannot obtain sufficient information about these details. The late binder uses managed reflection to try to determine these details. The late binder assumes that such method calls involve a ByRef parameter and that the property that you pass has a set accessor. If the property that you pass does not have a set accessor, the Microsoft .NET Framework generates a MissingMethodException exception. The late binder handles the MissingMethodException exception.
The .NET Framework generates a MissingMethodException exception when the call to a method of a Microsoft Office object returns a HRESULT value of COR_E_MISSINGMETHOD. The Microsoft Office object is a COM object. Visual Basic .NET incorrectly assumes that all the methods of Microsoft Office objects return COR_E_MISSINGMETHOD if the property that you pass does not have a set accessor. However, not all the methods of Microsoft Office objects return COR_E_MISSINGMETHOD if the property that you pass does not have a set accessor. Therefore, the behavior that is mentioned in the “Symptoms” section of this article occurs if you pass a property that does not have a set accessor, such as the UserProperty.Name property, to a method.
Note This behavior does not occur if you use early-bound Microsoft Office objects.