Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 941863 - Last Review: December 3, 2007 - Revision: 1.2
You may receive a System.ArgumentException exception when you use the XmlSerializer constructor to serialize a custom data type in a .NET Framework 2.0 application
SYMPTOMS
Consider the following scenario:
- In a Microsoft .NET Framework 2.0 application, you use the XmlSerializer constructor to serialize a custom data type.
- You do this by using an environment variable.
In this scenario, you receive the following exception error message:
System.ArgumentException
Item has already been added. Key in dictionary: temp, Key being added: temp
CAUSE
This problem occurs because two environment variables have the same name. For example, one environment variables is named
temp, and another is named
TEMP.
RESOLUTION
To resolve this problem, use one of the following methods:
- Manually delete the duplicate variable. To do this, follow these steps:
- In Control Panel, open System.
- On the Advanced tab, click Environment Variables.
- Perform one of the following actions:
- Select the duplicate environment variable, and then click Delete.
- Click Edit to rename the duplicate variable.
- Use the Setx.exe tool in a program to delete the duplicate variable.
- Use the Sgen.exe tool to generate serialization assemblies. This method helps avoid duplicate environment variables.
STATUS
You cannot use duplicate environment variables.
This behavior is by design.
REFERENCES
For more information about environment variables, click the following article numbers to view the articles in the Microsoft Knowledge Base:
310519Â
(http://kbalertz.com/Feedback.aspx?kbNumber=310519/
)
How to manage environment variables in Windows XP
311933Â
(http://kbalertz.com/Feedback.aspx?kbNumber=311933/
)
How to specify environment variables in project settings by using Visual C++ .NET or Visual C++ 2005
195050Â
(http://kbalertz.com/Feedback.aspx?kbNumber=195050/
)
How to clear environment variables using Setx.exe
For more information about the Sgen.exe tool, visit the following Microsoft Developer Network (MSDN) Web site:
APPLIES TO
- Microsoft .NET Framework 2.0
| kbtshoot kbxml kbprb kbexpertiseadvanced kbdotnetservices KB941863 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please