这个新的SL应用程序是我的解决方案的入口点,基本上从其他xap文件加载主页。 检查更新等
我从MyApp中删除了App.xaml和App.xs文件 因为Loader现在是应用程序 我将相关代码从MyApp - App.cs复制到Loader - App.cs 我将相关代码从MyApp - App.xaml添加到Loader - App.xaml 这主要是WebContext的东西。问题是RIA Services为Loader 生成的代码与MyApp代码的代码不同
生成的MyApp代码包含以下命名空间:
MyApp的 MyApp.Web MyApp.Web.Models MyApp.Web.Services生成的Loader代码包含命名空间:
装载机Loader - App.cs中的以下代码行抛出InvalidOperationException 。
WebContext.Current.Authentication.LoadUser(this.Application_UserLoaded, null);异常的错误消息是:
I started with the Silverlight Business Application Template I will call this MyApp and MyApp.Web I added a new SL application project. and added a ria link to the existing web project. I will call this LoaderDomainContextType为null或无效,并且没有从AuthenticationBase<T>生成的上下文
This new SL app is the entry point of my solution, and basically loads the mainpage from the other xap file. Checks for updates, etc.
I removed the App.xaml and App.xs files from MyApp Because Loader is now the Application I copied the relevant code from MyApp - App.cs to Loader - App.cs I added the relevant code from MyApp - App.xaml to Loader - App.xaml Mostly this is the WebContext stuff.The problem is that the RIA Services generated code for Loader is not the same code as the code for MyApp
The generated code for MyApp contains the following namespaces:
MyApp MyApp.Web MyApp.Web.Models MyApp.Web.ServicesThe generated code for Loader contains the namespace:
LoaderThe following line of code in Loader - App.cs throws InvalidOperationException.
WebContext.Current.Authentication.LoadUser(this.Application_UserLoaded, null);The error msg for the exception is:
The DomainContextType is null or invalid and there are no contexts generated from AuthenticationBase<T>
最满意答案
我今天遇到了同样的问题(有类似的设置)。 看了一下之后,我在silverlight论坛上找到了这个帖子,它有答案(在底部查找解决方案,因为RIA Services中有一些API更改)。
简而言之,问题是您的WebContext无法找到在您的情况下处理LoadUser的DomainContext(在本例中为AuthenticationContext )。 要解决此问题,您需要将以下内容添加到App.xaml :
<Application.ApplicationLifetimeObjects> <dmnsvc:WebContext> <dmnsvc:WebContext.Authentication> <appsvc:FormsAuthentication> <appsvc:FormsAuthentication.DomainContext> <!--Your AuthenticationContext here--> </appsvc:FormsAuthentication.DomainContext> </appsvc:FormsAuthentication> </dmnsvc:WebContext.Authentication> </dmnsvc:WebContext> </Application.ApplicationLifetimeObjects>希望这可以帮助 :)
I've had this same problem (with a similar setup) today. After looking around a little bit, I found this post on the silverlight forums which has the answer (look in the bottom for the solution, since there were some API changes in RIA Services).
Long story short, the issue is that your WebContext can't find the DomainContext (in this case an AuthenticationContext) that handles LoadUser in your case. to solve this problem you'll need to add the following to your App.xaml:
<Application.ApplicationLifetimeObjects> <dmnsvc:WebContext> <dmnsvc:WebContext.Authentication> <appsvc:FormsAuthentication> <appsvc:FormsAuthentication.DomainContext> <!--Your AuthenticationContext here--> </appsvc:FormsAuthentication.DomainContext> </appsvc:FormsAuthentication> </dmnsvc:WebContext.Authentication> </dmnsvc:WebContext> </Application.ApplicationLifetimeObjects>Hope this helps :)
更多推荐
发布评论