.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 ‘IO’

PRB: “System.Reflection.TargetInvocationException” Error Message When You Call the MethodInfo.Invoke Method

Symptoms
When you call the MethodInfo.Invoke method, you may receive the following error message:

An unhandled exception of type ‘System.Reflection.TargetInvocationException’ occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.
You may also receive an additional error message that is similar to the following error message:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.IO.FileLoadException: ‘ClassLibrary1′ is not a valid file.
File name: “ClassLibrary1″
at ClassLibrary2.Class1.GetString()
Resolution
You receive the System.Reflection.TargetInvocationException error because the common language runtime calls the MethodInfo.Invoke method by using reflection.
When you load an assembly by using the Assembly.LoadFrom method, the common language runtime places the loaded assembly in the LoadFrom context of your application. Any probes for the dependencies of the assembly first probe the current application directory. If this probe fails, the common language runtime then probes the LoadFrom context of your application.
You may load an assembly that has a simply-named dependency that has the same file name as a file in the current application directory. When you try to invoke a method in the loaded assembly by using the MethodInfo.Invoke method, and the invoked method uses the dependency, the common language runtime first probes the current directory path. When the common language runtime finds a file that has the same file name as the dependency, the probe stops. However, if this file does not have the same assembly identity as the dependency, the assembly bind fails, and the common language runtime generates a System.IO.FileLoadException error that is passed to the System.Reflection.TargetInvocationException error. Therefore, you may notice the behavior that is mentioned in the “Symptoms” section.

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.

Event IDs 106 and 107 may be logged in the System log on a Windows Server 2003-based computer

Symptoms
When you use Event Viewer to view the System log on a Microsoft Windows Server 2003-based computer, you may see event messages that are similar to the following:
Event ID: 107
Source:WMIxWDM
Description: Machine check event reported is a fatal error.
Event ID: 106
Source: WMIxWDM
Description:Machine check event reported is a corrected error.
MessageId=0×0078 Facility=Mca Severity=Error
SymbolicName=MCA_MEMORYHIERARCHY_ERROR
Language=English
Machine Check Event reported is a fatal memory hierarchy error.%r
Trasaction Type: %1%r
Memory Hierarchy Level: %2%r
Request Type: %3%r
Address: %4
MessageId=0×0079 Facility=Mca Severity=Error
SymbolicName=MCA_TLB_ERROR
Language=English
Machine Check Event reported is a fatal TLB error.%r
Transaction Type: %1%r
Memory Hierarchy Level: %2%r
Address: %3
MessageId=0×007a Facility=Mca Severity=Error
SymbolicName=MCA_BUS_ERROR
Language=English
Machine Check Event reported is a fatal Bus or Interconnect error.%r
Memory Hierarchy Level: %1%r
Participation: %2%r
Request Type: %3%r
Memory/IO: %4%r
Address: %5
MessageId=0×007b Facility=Mca Severity=Error
SymbolicName=MCA_BUS_TIMEOUT_ERROR
Language=English
Machine Check Event reported is a fatal Bus or Interconnect timeout error.%r
Memory Hierarchy Level: %1%r
Participation: %2%r
Request Type: %3%r
Memory/IO: %4%r
Address: %5
MessageId=0×007c Facility=Mca Severity=Error
SymbolicName=MCA_INTERNALTIMER_ERROR
Language=English
Machine Check Event reported is a fatal internal watchdog timer error.
MessageId=0×007e Facility=Mca Severity=Error
SymbolicName=MCA_MICROCODE_ROM_PARITY_ERROR
Language=English
Machine Check Event reported is a fatal microsoft ROM parity error.
MessageId=0×007f Facility=Mca Severity=Error
SymbolicName=MCA_EXTERNAL_ERROR
Language=English
Machine Check Event reported is a fatal condition. A processor received an external signal that an unrecoverable error has occurred.
MessageId=0×0080 Facility=Mca Severity=Error
SymbolicName=MCA_FRC_ERROR
Language=English
Machine Check Event reported is a fatal functional redundancy check error.
Resolution
These event messages may be logged in the System log in response to a Machine Check Architecture exception. A Machine Check Architecture exception is sent by the CPU in the computer in response to a computer error. The computer error may cause the computer to restart. After the computer has restarted, the CPU reports the Machine Check Architecture exception to the hardware abstraction layer (HAL). The HAL uses Windows Management Instrumentation (WMI) to report the Machine Check Architecture exception to the operating system.The operating system then logs the Machine Check Architecture exception in the System log as an event ID.

Error message when you use the “IMSAdminBase::CopyKey” method as a part of the IIS 6.0 Compatibility components in IIS 7.0: “Exception from HRESULT: 0×80070003″

Symptoms
When you use the IMSAdminBase::CopyKey method as part of the IIS 6.0 Compatibility components that are included with IIS 7.0, the ApplicationHost.config file becomes corrupted. Additionally, you receive the following error message when you run a Microsoft .NET Framework application that tries to read the configuration file:

Unhandled Exception: System.IO.DirectoryNotFoundException: The system cannot find the path specified. (Exception from HRESULT: 0×80070003)The following error message is logged in the ABO Mapper log file:

Failed to generate custom nodes.error = 800700b7
Resolution
Hotfix information A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.
If the hotfix is available for download, there is a “Hotfix download available” section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.
Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or tocreate a separate service request, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support(http://support.microsoft.com/contactus/?ws=support)Note The “Hotfix download available” form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.PrerequisitesTo apply this hotfix, you must have IIS 7.0 and the IIS 6.0 Compatibility componentsinstalled.Restart requirementYou mustrestart the computer after you apply this hotfix.Hotfix replacement information This hotfix does not replace any other previously released hotfixes. Registry information To use this hotfix, you do not have to make any changes to the registry. File informationThe English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.x86-based versions
Collapse this tableExpand this table
File nameFile versionFile sizeDateTimePlatformAbocomp.dll7.0.6001.22154209,40810-Apr-200804:57×86Coadmin.dll7.0.6001.2215475,77610-Apr-200804:57×86Iisadmin.dll7.0.6001.2215420,48010-Apr-200804:59×86Iiscfg.dll7.0.6001.22154991,74410-Apr-200804:59×86Inetinfo.exe7.0.6001.2215413,82410-Apr-200803:15×86Infoadmn.dll7.0.6001.2215416,38410-Apr-200804:59×86Infocomm.dll7.0.6001.22154227,32810-Apr-200804:59×86Infoctrs.dll7.0.6001.221549,72810-Apr-200804:59×86Infoctrs.hNot Applicable3,27618-Dec-200721:05Not ApplicableInfoctrs.iniNot Applicable22,87218-Dec-200721:05Not ApplicableIsatq.dll7.0.6001.2215455,29610-Apr-200804:59×86Iscomlog.dll7.0.6001.2215419,96810-Apr-200804:59×86Metadata.dll7.0.6001.22154268,28810-Apr-200805:00×86Rpcref.dll7.0.6001.221547,68010-Apr-200805:02×86Wamreg.dll7.0.6001.2215432,25610-Apr-200805:02×86x64-based versions
Collapse this tableExpand this table
File nameFile versionFile sizeDateTimePlatformAbocomp.dll7.0.6001.22154229,88810-Apr-200805:22×64Coadmin.dll7.0.6001.2215482,94410-Apr-200805:23×64Iisadmin.dll7.0.6001.2215424,06410-Apr-200805:25×64Iiscfg.dll7.0.6001.221541,058,30410-Apr-200805:25×64Inetinfo.exe7.0.6001.2215415,87210-Apr-200803:51×64Infoadmn.dll7.0.6001.2215422,52810-Apr-200805:25×64Infocomm.dll7.0.6001.22154270,33610-Apr-200805:25×64Infoctrs.dll7.0.6001.2215412,28810-Apr-200805:25×64Infoctrs.hNot Applicable3,27618-Dec-200721:06Not ApplicableInfoctrs.iniNot Applicable22,87218-Dec-200721:06Not ApplicableIsatq.dll7.0.6001.2215464,51210-Apr-200805:26×64Iscomlog.dll7.0.6001.2215423,04010-Apr-200805:26×64Metadata.dll7.0.6001.22154284,67210-Apr-200805:26×64Rpcref.dll7.0.6001.221549,21610-Apr-200805:28×64Wamreg.dll7.0.6001.2215437,88810-Apr-200805:29×64Abocomp.dll7.0.6001.22154209,40810-Apr-200804:57×86Coadmin.dll7.0.6001.2215475,77610-Apr-200804:57×86Iisadmin.dll7.0.6001.2215420,48010-Apr-200804:59×86Iiscfg.dll7.0.6001.22154991,74410-Apr-200804:59×86Infoadmn.dll7.0.6001.2215416,38410-Apr-200804:59×86Infocomm.dll7.0.6001.22154227,32810-Apr-200804:59×86Infoctrs.dll7.0.6001.221549,72810-Apr-200804:59×86Isatq.dll7.0.6001.2215455,29610-Apr-200804:59×86Iscomlog.dll7.0.6001.2215419,96810-Apr-200804:59×86Metadata.dll7.0.6001.22154268,28810-Apr-200805:00×86Rpcref.dll7.0.6001.221547,68010-Apr-200805:02×86Wamreg.dll7.0.6001.2215432,25610-Apr-200805:02×86IA-64-based versions
Collapse this tableExpand this table
File nameFile versionFile sizeDateTimePlatformAbocomp.dll7.0.6001.22154521,72810-Apr-200805:10IA-64Coadmin.dll7.0.6001.22154193,02410-Apr-200805:12IA-64Iisadmin.dll7.0.6001.2215454,78410-Apr-200805:15IA-64Iiscfg.dll7.0.6001.221541,382,40010-Apr-200805:15IA-64Inetinfo.exe7.0.6001.2215428,16010-Apr-200803:43IA-64Infoadmn.dll7.0.6001.2215440,44810-Apr-200805:15IA-64Infocomm.dll7.0.6001.22154555,00810-Apr-200805:15IA-64Infoctrs.dll7.0.6001.2215424,06410-Apr-200805:15IA-64Infoctrs.hNot Applicable3,27618-Dec-200721:06Not ApplicableInfoctrs.iniNot Applicable22,87218-Dec-200721:06Not ApplicableIsatq.dll7.0.6001.22154139,26410-Apr-200805:15IA-64Iscomlog.dll7.0.6001.2215451,20010-Apr-200805:15IA-64Metadata.dll7.0.6001.22154569,34410-Apr-200805:15IA-64Rpcref.dll7.0.6001.2215414,33610-Apr-200805:18IA-64Wamreg.dll7.0.6001.2215477,31210-Apr-200805:19IA-64Abocomp.dll7.0.6001.22154209,40810-Apr-200804:57×86Coadmin.dll7.0.6001.2215475,77610-Apr-200804:57×86Iisadmin.dll7.0.6001.2215420,48010-Apr-200804:59×86Iiscfg.dll7.0.6001.22154991,74410-Apr-200804:59×86Infoadmn.dll7.0.6001.2215416,38410-Apr-200804:59×86Infocomm.dll7.0.6001.22154227,32810-Apr-200804:59×86Infoctrs.dll7.0.6001.221549,72810-Apr-200804:59×86Isatq.dll7.0.6001.2215455,29610-Apr-200804:59×86Iscomlog.dll7.0.6001.2215419,96810-Apr-200804:59×86Metadata.dll7.0.6001.22154268,28810-Apr-200805:00×86Rpcref.dll7.0.6001.221547,68010-Apr-200805:02×86Wamreg.dll7.0.6001.2215432,25610-Apr-200805:02×86

BUG: XmlTextReader Decodes URLs Before Downloading Resources Resulting in Unpredictable Behavior

Symptoms
When you use the XmlTextReader object to download resource files, the reader decodes the URL for the resources. If the URL contains any special characters (for example, ampersands or percent signs), this may result in unpredictable behavior.
Resolution
To resolve the problem, follow these steps: Use the XmlUrlResolver and the System.IO.Stream classes to map the specified URL.Create an XmlTextReader object and pass the Stream as the parameter. For an example, see the “More Information” section of this article.