1
我正在为我的Silverlight应用程序实现自定义身份验证。如果这个代码在我的app.xaml中: -app.xaml/app.xaml.cs问题自定义身份验证
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SilverlightCustomAuthExample.App"
xmlns:local="clr-namespace:SilverlightCustomAuthExample"
xmlns:appsvc="clr-namespace:System.ServiceModel.DomainServices.Client.ApplicationServices;assembly=System.ServiceModel.DomainServices.Client.Web"
>
<Application.Resources>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<local:WebContext>
<local:WebContext.Authentication>
<appsvc:FormsAuthentication/>
</local:WebContext.Authentication>
</local:WebContext>
</Application.ApplicationLifetimeObjects>
</Application>
它工作正常。但是,如果我尝试做同样的事情在app.xaml.cs它不工作: -
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
WebContext.Current.Authentication = new FormsAuthentication();
}
它说WebContext.Current
抛出异常InvalidOperationException异常。
在此先感谢:)
什么是新的App.xaml(的情况下它崩溃)? – Timores 2010-11-11 12:18:33