0

facing the above error in below resource

<Window.Resources>
   <viewmodel:MyViewModel x:Key="venue"></viewmodel:MyViewModel>
</Window.Resources>

my app.config in client side

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IService" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:65107/MyDataService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
            contract="MyService.IService" name="BasicHttpBinding_IService" />
    </client>
</system.serviceModel>

my web.config defined for wcf service (copied service model part alone)

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>              
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />              
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpBinding" scheme="http" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

and also there is error during window initialization

initialization of 'MySystem.Launcher.MainWindow' threw an exception An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll Inner exception : Cannot have nested BeginInit calls on the same instance

private MyViewModel vm;
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                vm = new MyViewModel();
                this.DataContext = vm;
            }
            catch(Exception e)
            {

            }
        }

Any help is greatly appreciated

Mong Zhu
  • 23,309
  • 10
  • 44
  • 76
CodeDada
  • 425
  • 1
  • 11
  • 24
  • Why are you adding a view model to the section of your view and what are you doing in the constructor of the view model? – mm8 Dec 20 '16 at 15:36
  • Wait, the title doesn't fit the error in your question at all. Also, why have your VM constructed in a resource (a BAD idea if you're doing work that relies on app.config in its constructor, see here http://stackoverflow.com/questions/38209933/no-connection-string-named-x-found-in-application-config-file-but-it-works), AND set it in the window's constructor? What are you trying to do here? What's happening? Where is it happening? –  Dec 20 '16 at 15:43
  • @mm8 and @ Will ,I have added view model in the resources for static resource binding of controls to view model properties – CodeDada Dec 20 '16 at 17:13

0 Answers0