开发者

WPF - how to call another WPF with own service refences?

I have 2 WPF projects in 1 solution. Every of those projects have different service references. First project it's a window to login, second is a main window with app. It must be in separated projects, don't ask why.

So, I do main window reference in login project and create main window object when login data is corect. Here sample of code:

try
{
    if (Service1.Login(login, pass))
    {
        MainWindow w2 = new MainWindow();
        w2.Show();
        this.Close();
    }
}
catch (Exception ex)
{
//...
}

My problem is error occured when main window is called. Main exception is like this:

"Cannot create instance of 'MainWin开发者_开发百科dow' defined in assembly 'TestApp, Version=1.0.0.0, 
Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an 
invocation.  Error in markup file 'MainWindow.xaml' Line 1 Position 9." 

Inner exception told me something like:

"Cannot found endpoint of service..."

But when I run just main window project as startup it works good. Is there any "proper" method to call other WPFs whit service references? Or I must to do something with references?


There is nothing wrong in your architecture (even if we can discuss about it), this is more a WCF question. Your problem comes from the fact that your Login app config file hos no endpoint defined for the MainWindow's service.

The Login app.config should contain two <endpoint .../> tags in the <configuration><system.serviceModel><client> section.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜