У меня есть приложение WPF, содержащее службу WCF.
Код Xaml довольно прост:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Server" Height="308" Width="560" >
<Grid>
<Grid Margin="2,2,0,0" Name="grid1">
<RichTextBox Margin="14,29,12,39" Name="richTextBox1" />
<TextBox Height="24" Margin="16,0,80,9" Name="textBox1" VerticalAlignment="Bottom">Enter your text here</TextBox>
<Button Height="24" HorizontalAlignment="Right" Margin="0,0,12,9" Name="button1" VerticalAlignment="Bottom" Width="63">Send</Button>
<Label Height="23" Margin="16,0,12,0" Name="label1" VerticalAlignment="Top">Address:</Label>
</Grid>
</Grid>
</Window>
Вот услуга:
пространство имен WpfApplication1
{
[ServiceContract(CallbackContract=typeof(IMyCallbackContract))]
public interface IMyService
{
[OperationContract(IsOneWay = true)]
void NewMessageToServer(string msg);
[OperationContract(IsOneWay = true)]
bool ServerIsResponsible();
}
[ServiceContract]
public interface IMyCallbackContract
{
[OperationContract]
void NewMessageToClient(string msg);
[OperationContract]
void ClientIsResponsible();
}
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
ServiceMetadataBehavior behavior = new
ServiceMetadataBehavior();
//behavior.HttpGetEnabled = true;
//behavior.
ServiceHost serviceHost = new
ServiceHost(
typeof(MyService),
new Uri("net.tcp://localhost:8080/"));
serviceHost.Description.Behaviors.Add(behavior);
serviceHost.AddServiceEndpoint(
typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexTcpBinding(),
"mex");
serviceHost.AddServiceEndpoint(
typeof(IMyService),
new NetTcpBinding(),
"ServiceEndpoint");
serviceHost.Open();
MessageBox.Show(
"server is up");
// label1.Content = label1.Content + String.Format(" net.tcp://localhost:8080/");
}
}
public class MyService : IMyService
{
public void NewMessageToServer(string msg)
{
}
public bool ServerIsResponsible()
{
return true;
}
}
}
В строке 1 получено исключение синтаксического анализа Xaml. В чем может быть проблема?
Спасибо!