“The invocation of the constructor on type 'TestWPF.MainWindow' that matches the specified binding constraints threw an exception.”- how to fix this?

后端 未结 15 2153
遥遥无期
遥遥无期 2020-12-03 09:51

I\'m working with WPF. When I\'m trying to declare SQLiteConnection in the code, the problem arises-

The invocation of the constructor on type \         


        
相关标签:
15条回答
  • 2020-12-03 10:20

    Try Adding "Integreted Security = True" in Connection String. It worked for me.

    0 讨论(0)
  • 2020-12-03 10:21

    I ran into this issue and it was caused because my startup application was built as any CPU but I was referencing a project that was built as x64. Setting the startup to build x64 resolved the issue.

    0 讨论(0)
  • 2020-12-03 10:22

    I got the same error and, after wasting about 2 hours with it, found that it is my SQL Server service that's not running. Not sure if this can ever help someone, but it did solve my problem to just start the service.

    0 讨论(0)
  • 2020-12-03 10:24

    In my specific case, I was getting this because I had a few of my referencing assemblies mismatched between x64 and x86. Apparently I was binding to something that needed to be loaded by the runtime.

    I mention this here as a reminder to check your build configurations if you've looked everywhere else!

    0 讨论(0)
  • 2020-12-03 10:27

    I got it in when I specified the FrameworkPropertyMetadata of a DependencyProperty with a default value

    the defaultValue was

    new AdressRecord { Name = "<new>", Adress = "?" }
    

    i replaced with

    default(AddressRecord)
    

    and vs2015 ate it

       public static readonly DependencyProperty AdressRecordsProperty =
           DependencyProperty.Register("AdressRecords", 
               typeof(ObservableCollection<AdressRecord>), 
               typeof(PageViewModel), 
               new FrameworkPropertyMetadata(
                   default(AdressRecord),//This noes not work: new AdressRecord { Name = "<new>", Adress = "?" },
                   OnAdressRecordsChanged));
    
    0 讨论(0)
  • 2020-12-03 10:27

    With Visual Studio it will sometimes not show anything in the exception details or even have them, running the diagnostic tool however can easily pinpoint what is wrong.

    0 讨论(0)
提交回复
热议问题