You receive a "System.IO.FileNotFoundException" exception error message when you serialize an object to XML in a Visual Studio .NET or Visual Studio 2005 project (884466)
The information in this article applies to:
- Microsoft Visual Studio 2005 Professional Edition
- Microsoft Visual Studio 2005 Standard Edition
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Professional Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
SYMPTOMSYou receive the following exception error message when you try to serialize an object in a Microsoft Visual Studio .NET or Microsoft Visual Studio 2005 application: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: File or assembly name <AssemblyName>, or one of its dependencies, was not found. Note AssemblyName is a placeholder for the assembly name that the computer generates at run time. You may receive the same exception error message when you try to deserialize a serialized object in an application that has the Serialization namespace as the root namespace. CAUSEWhen you serialize custom classes, the Microsoft .NET Framework makes a private compilation of some code. Therefore, this problem occurs when the root namespace of your project is Serialization and your project includes the System.XML.Serialization namespace.
For example, if your custom class is named OrderedItem, the qualified name of the OrderedItem class is Serialization.OrderedItem. This name conflicts with the name of the System.Xml.Serialization namespace. Because the two names conflict, the compiler cannot find the OrderedItem class.
WORKAROUNDTo work around this problem, change the RootNamespace property in the project properties. To do this, follow these steps: Note Before you change the root namespace, make sure that all the files and forms of that project are closed. - In Solution Explorer, right-click Serialization.
- Click Properties.
The Serialization Property Pages dialog box appears. - In the left pane, click General under Common Properties.
- In the right pane, change "Serialization" to "Serialization1" in the Root namespace box.
REFERENCESFor more information, visit the following Microsoft Developer Network (MSDN) Web site:
For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
314150
Roadmap for XML serialization in the .NET Framework
815813 Serialize an object to XML by using Visual C# .NET
316730 Serialize and deserialize XML in Visual Basic .NET
823196 You receive a "System.IO.FileNotFoundException" error when the client application calls a Web service
Modification Type: | Major | Last Reviewed: | 2/28/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbXML kbSerial kberrmsg kbtshoot kbprb KB884466 kbAudDeveloper |
---|
|