DatePicker.Value.Set Błąd wiązania ze źródłem danych

Mam formant bindingsource o nazwie bind na formularzu w VS2012 i kontrolkę DateTimePicker związaną z nią.

dla właściwości wiązania mam MinDate = 1/01/1753 i MaxDate = 31/12/9998 Wartość została ustalona przez wybranie Dzisiaj z kalendarza 5/04/2013 11:27

Ustawiłem bindingsource używając

var dset = base.Context.ContactEvents;
var qry = dset.Where(p => p.Id > 0).OrderBy(x => x.Id);
qry.Load();
this.bindingSource.DataSource = dset.Local.ToBindingList();

Źródło powiązań jest używane w następujący sposób;

 public void RefreshBindingDataSourceAndPosition(BindingSource binding)
  {
    binding.DataSource = this.bindingSource.DataSource;  // error raised here
    binding.Position = this.bindingSource.Position;
  }

Informacje o błędzie to

System.ArgumentOutOfRangeException przekroczył granicę rodzimą / zarządzaną HResult = -2146233086 Komunikat = Wartość „1/01/0001 12:00:00 AM” nie jest prawidłowa dla „Wartość”. „Wartość” powinna znajdować się między „MinDate” a „MaxDate”. Nazwa parametru: Wartość Źródło = System.Windows.Forms ParamName = Wartość StackTrace: at System.Windows.Forms.DateTimePicker.set_Value (wartość DateTime) InnerException:

Mogę obejść ten problem, nie wiążąc selektora danych i ustawiając go w zdarzeniu EventsBindingSource_CurrentChanged

Jednak wydaje się dziwne, że trzeba to robić. Jak mogę uzyskać powiązanie danych?

[Aktualizacja] Ten problem jest podobny do opisanegotutaj Próbowałem odtworzyć problem w prostszym projekcie, aby spróbować wyizolować przyczynę, jednak działa to w prostszym projekcie. Również projekt działa na innym komputerze. Problem występuje na moim komputerze z SQL Server 2012 i 2008R2. Próbowałem zmienić format daty i kraj w panelu sterowania. Próbowałem też różnych ustawień właściwości formatu. Próbowałem również ustawić pole daty, aby obsługiwało wartość null.

Kiedy kopiuję błąd do schowka, pokazuje następujące;

Wystąpił wyjątek System.Reflection.TargetInvocationException HResult = -2146232828 Message = Wyjątek został zgłoszony przez cel wywołania. Source = mscorlib StackTrace: at System.RuntimeMethodHandle.InvokeMethod (Object target, argumenty Object [], Signature sig, konstruktor boolowski) w System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal (Object obj, Object [] parametry, Object [] argumenty) InnerException: System.ArgumentOutOfRangeException HResult = -2146233086 Komunikat = Wartość „1/01/0001 12:00:00 AM” nie jest prawidłowa dla „Wartość”. „Wartość” powinna znajdować się między „MinDate” a „MaxDate”. Nazwa parametru: Wartość Źródło = System.Windows.Forms ParamName = Wartość StackTrace: at System.Windows.Forms.DateTimePicker.set_Value (wartość DateTime) InnerException:

Moja klasa EF jest następująca

public class ContactEvent : LoggedEntity
{

    public virtual SortableBindingList<ContactEventAttendee> Attendees { get; private set; }
    public virtual ContactEventType ContactEventType { get; set; }
    public string Details { get; set; }
    public DateTime? EventTime { get; set; }
    public virtual SortableBindingList<ContactEventItem> Items { get; private set; }
    public int State { get; set; }
    public string Title { get; set; }
    public override string ToString()
    {
        return "Contact Events";
    }
}

dziedziczy z

public abstract class LoggedEntity
{

   public LoggedEntity()
    {
        this.RowId = Guid.NewGuid();
        this.RowVersionId = 0;
        AppDomain dm = AppDomain.CurrentDomain;  // Gets the current application domain for the current Thread.
        object s = AppDomain.CurrentDomain.GetData("SiteNumber");
        this.SourceSiteNumber = Convert.ToInt32(s);
    }

    public LoggedEntity(int SiteNumber)
    {
        // the following 3 are used to identify the version 
        this.RowId = Guid.NewGuid();
        this.RowVersionId = 0;
        this.SourceSiteNumber = SiteNumber;
    }

    public int Id { get; set; }
    public Guid RowId { get; set; }

    [ConcurrencyCheck]
    public int RowVersionId { get; set; }
    public int SourceSiteNumber { get; set; }

}

[aktualizacja] Podobny problemtutaj

[aktualizacja] Innytutaj każe mi myśleć, że muszę przyjrzeć się, jak przetwarzane są klucze.

[update] Zauważyłem następujące informacje w oknie wyjściowym

A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll

[aktualizacja] To doprowadziło mnie dotutaj

i po włączeniu opcji debugowania znalazłem błąd

Invalid object name 'dbo.__MigrationHistory'.

jest to jednak znany błąd w EF5

[Aktualizacja]: Znalazłem inną osobę z podobnymi nierozwiązanymi problemamitutaj Wykryty Nie mam problemów z uruchomieniem .EXE

[aktualizacja] Mogę pominąć błąd, wyłączając „Przerwij, gdy wyjątki przekraczają domenę aplikacji lub zarządzaną / rodzimą granicę w menu Narzędzia-> Opcje-> Debugowanie-> Ogólne

[update] Dodaję następujące, więc mógłbym sprawdzić właściwości kontrolne.

    private void EventsBindingSource_BindingComplete(object sender, BindingCompleteEventArgs e)
    {
        // If the BindingComplete state is anything other than success, 
        // set the ErrorProvider to the error message.
        if (e.BindingCompleteState != BindingCompleteState.Success)
        {
            errorProvider1.SetError((Control)e.Binding.BindableComponent, e.ErrorText);
            var errdesc = e.ErrorText;
            var ctrl = (Control)e.Binding.BindableComponent;
              var info = string.Format(
               "{0} {1}",errdesc,
               ctrl.ToString());

            Debug.Print(info);
            // "Value of '1/1/0001 12:00:00 AM' is not valid for 'Value'. 
             'Value' should be between 'MinDate' and 'MaxDate'.\r\nParameter name: 
             Value System.Windows.Forms.DateTimePicker, Value: 1/1/1900 12:00:00 AM"

        }
        else
        {
            errorProvider1.SetError((Control)e.Binding.BindableComponent, "");
        }
    }

questionAnswers(2)

yourAnswerToTheQuestion