找不到在xaml中引用契约的默认端点元素

时间:2016-12-20 15:00:18

标签: c# wpf wcf xaml mvvm

在资源

中遇到上述错误
<Window.Resources>
   <viewmodel:MyViewModel x:Key="venue"></viewmodel:MyViewModel>
</Window.Resources>

我在客户端的app.config

<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>

为wcf服务定义的web.config(仅复制服务模型部分)

<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>

并且窗口初始化期间也出现错误

  

初始化&#39; MySystem.Launcher.MainWindow&#39;抛出一个例外       类型&#39; System.Windows.Markup.XamlParseException&#39;的未处理异常发生在PresentationFramework.dll中       内部异常:不能在同一实例上嵌套BeginInit调用

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

            }
        }

非常感谢任何帮助

0 个答案:

没有答案