Microsoft Knowledge Base Email Alertz

KBAlertz.com: 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

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








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:
    1. In Control Panel, open System.
    2. On the Advanced tab, click Environment Variables.
    3. 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:
http://msdn2.microsoft.com/en-us/library/bk3w6240(VS.80).aspx (http://msdn2.microsoft.com/en-us/library/bk3w6240(VS.80).aspx)

APPLIES TO
  • Microsoft .NET Framework 2.0
Keywords: 
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