.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 Tagged ‘exception error’

FIX: You receive exception error messages when you use the StreamWriter.Flush () method or the StreamWriter.Close () method to access a file on a disk that has insufficient space in .NET Framework 1.1

Symptoms
On a computer that is running Microsoft .NET Framework 1.1, when you use the StreamWriter.Flush() method or the StreamWriter.Close() method to access a file on a disk that has insufficient space, you receive the following exception error message:

System.IO.IOException: There is not enough space on the disk.After you free up space on the disk and then try to access the file again, you receive the following exception error message:

System.IO.IOException: The process cannot access the file “C:\outputTest.txt” because it is being used by another process.
Resolution
This problem occurs if the common language runtime (CLR) does not close the file handle after you receive the first exception error message. If the file handle does not close, you cannot access the file regardless of how much space is on the disk.

FIX: Floating Point Exception (Error 3628) Might Occur for Queries That Need Merged Histograms

Symptoms
The following floating-point exception error message might occur for queries that require a “merged” histogram:

Server: Msg 3628, Level 16, State 1, Line 2 A floating point exception occurred in the user process. Current transaction is canceled.
Resolution
A float overflow exception occurs in SQL Server when it combines the histograms for two indexes to handle the cardinality estimation for outer-join operators.

FIX: A System.ArgumentException exception occurs when you try to create a Windows form that inherits from a Windows form that contains a dataset

Symptoms
When you try to create a Windows form that inherits from a Windows form that contains a dataset in Microsoft Visual Studio .NET 2003, you may receive the following exception error message:

An unhandled exception of type ‘System.ArgumentException’ occurred in system.data.dll
Additional information: Cannot add primary key constraint since primary key is already set for the table.
Resolution
If the dataset contains nested datatables, Visual Studio .NET incorrectly tries to add additional code to the inherited Windows form to enforce constraints on the inherited dataset. This code tries to add a constraint that already exists on the dataset. Therefore, the behavior that is mentioned in the “Symptoms” section occurs.

Exception Error in Nwconv.exe During Migration

Symptoms
When you attempt to migrate user accounts and data from Novell NetWare3.1x servers to Windows NT 3.5, 3.51, or 4.0 servers using the MigrationTool for Netware (Nwconv.exe), the Migration Tool for NetWare may stopresponding with an exception error 0xc0000005 in Nwconv.exe and generatea Drwtsn32.log file.
Resolution
During migration, the Migration Tool for NetWare builds a PrinterOperators member list. It enumerates all the print servers on the NetWareserver and then builds the user list of who is in the Printer Operatorgroup associated with the respective print server. The Migration Tool forNetWare sets a buffer size to hold a print server name less than or equalto 20 characters, including the null character. NetWare allows less thanor equal to 47 characters for the print server name. Unexpected resultsmay occur when you read a string into the buffer of a smaller size. Inthis case, the result is an exception error in Nwconv.exe.

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”); }}