Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 398057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:42:39+00:00 2026-05-12T16:42:39+00:00

I have a project created with VS2010. I am running the project from VS2008.

  • 0

I have a project created with VS2010. I am running the project from VS2008. Plz note that, I am not running the solution. I am only running the project. Fortunately the solution has only one project.

And in the following line I am having an exception.

List<Order> OrderList = new List<Order> {
new Order 
{OrderID = 10248, 
CustomerID = "VINET", 
EmployeeID = 5, 
OrderDate = DateTime.Parse("7/4/2006", CultureInfo.CreateSpecificCulture("en-US")),
RequiredDate = DateTime.Parse("8/1/2006", CultureInfo.CreateSpecificCulture("en-US")),
ShippedDate = DateTime.Parse("7/16/2006", CultureInfo.CreateSpecificCulture("en-US")),
ShipVia = 3, Freight = 32.3800M, ShipName = "Vins et alcools Chevalier",
ShipCountry = "France", 
Order_Details = new List<Order_Detail>(), 
Customer = new Customer(), 
Employee = new Employee(), 
Shipper = new Shipper()}};

The exception is:

FormatException was unhandled:
String was not recognized as a valid DateTime.

Stack Trace is:

NwindObjectsCS.exe!NwindObjectsCS.frmMain.CreateOrderList() Line 142 C#
NwindObjectsCS.exe!NwindObjectsCS.frmMain.btnInitializer_Click(object sender = {Text = “Load (&Initializer)”}, System.EventArgs e = {X = 86 Y = 22 Button = Left}) Line 51 + 0xe bytes C#
[External Code]
NwindObjectsCS.exe!NwindObjectsCS.Program.Main() Line 18 + 0x1d bytes C#
[External Code]

What suppose to be the problem?

I have downloaded the code from WROX Web site. The code is from the book “Professional ADO.NET 3.5 with LINQ and the Entity Framework”. Author is “Roger Jennings”. So there should not be any problem.

It is from 3rd chapter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:42:39+00:00Added an answer on May 12, 2026 at 4:42 pm

    I tried this (My machine is set to “en-GB”):-

    static void Main(string[] _args)
    {
      DateTime d1 = DateTime.Parse("7/4/2006", CultureInfo.CreateSpecificCulture("en-GB"));
      DateTime d2 = DateTime.Parse("8/1/2006", CultureInfo.CreateSpecificCulture("en-GB"));
      DateTime d3 = DateTime.Parse("16/7/2006", CultureInfo.CreateSpecificCulture("en-GB"));
      System.Console.WriteLine("d1:" + d1.ToString());
      System.Console.WriteLine("d2:" + d2.ToString());
      System.Console.WriteLine("d3:" + d3.ToString());
      System.Console.ReadKey();
    }
    

    I get no errors. I then go into control panel, regional settings, customize, change my short date format to yyyy-mm-dd and re-run the prog. It then throws the same exception.
    Switching the locale completely doesn’t affect it though.

    It seems that if you’ve customised your regional settings for the region specified then it breaks.

    Have you customised the “en-US” regional date settings on your machine?

    Alternatives.

    ParseExact:-

    DateTime.ParseExact("16/7/2006", "d/M/yyyy", CultureInfo.InvariantCulture);
    

    Kobi’s suggestion:-

    DateTime.Parse("16/7/2006", new CultureInfo("en-GB", false));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.