volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

AI OnAI Off

Problem with EPiServer Languages add-on

Hi

I am setting up a demo site and having some issues with episerver langues add-on. 

Installed new Episerver web site project  "alloy mvc" from Visual studio.  I run the site and enables one extra language and enables new language in edit mode.

PM> Install-Package EPiServer.Labs.LanguageManager
Attempting to resolve dependency 'EPiServer.Packaging (≥ 3.2.0 && < 4.0)'.
Attempting to resolve dependency 'EPiServer.Framework (≥ 7.15.0 && < 8.0)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 5.0.8 && < 7.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.Mvc (≥ 4.0.20710.0 && < 6.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebPages (≥ 3.2.2 && < 3.3.0)'.
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.Razor (≥ 3.2.2 && < 3.3.0)'.
Attempting to resolve dependency 'structuremap (≥ 2.6.4.1 && < 3.0)'.
Attempting to resolve dependency 'Nuget.Core (≥ 2.5 && < 2.8)'.
Attempting to resolve dependency 'EPiServer.CMS.Core (≥ 7.5 && < 8.0)'.
Attempting to resolve dependency 'EPiServer.Logging.Log4Net (< 2.0)'.
Attempting to resolve dependency 'log4net (= 1.2.10)'.
Attempting to resolve dependency 'Castle.Windsor (≥ 3.2 && < 4.0)'.
Attempting to resolve dependency 'Castle.Core (≥ 3.2.0)'.
Attempting to resolve dependency 'EPiServer.CMS.UI (≥ 7.5 && < 8.0)'.
Attempting to resolve dependency 'EPiServer.CMS.UI.Core (= 7.17.0)'.
Attempting to resolve dependency 'DotNetZip (= 1.9.1.8)'.
Installing 'EPiServer.Labs.LanguageManager 1.1.1.7514'.
Successfully installed 'EPiServer.Labs.LanguageManager 1.1.1.7514'.
Adding 'EPiServer.Labs.LanguageManager 1.1.1.7514' to Demo2.
Successfully added 'EPiServer.Labs.LanguageManager 1.1.1.7514' to Demo2.



When i add the languages gadget i get this error (and languages gadgets is emty). It is possible to translate pages but the gadget is not working.

I have also tried installing add-on from store. Also tried updating all episerver nugets.

http://localhost:52901/EPiServer/EPiServer.Labs.LanguageManager/Stores/language/null Failed to load resource: the server responded with a status of 500 (Internal Server Error)
dojo.js:15 _317: Unable to load /EPiServer/EPiServer.Labs.LanguageManager/Stores/language/null status: 500
http://localhost:52901/EPiServer/EPiServer.Labs.LanguageManager/Stores/language/null Failed to load resource: the server responded with a status of 500 (Internal Server Error)
dojo.js:15 _317: Unable to load /EPiServer/EPiServer.Labs.LanguageManager/Stores/language/null status: 500message: "Unable to load /EPiServer/EPiServer.Labs.LanguageManager/Stores/language/null status: 500"response: ObjectresponseText: "
↵
↵    
↵        Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'EPiServer.Security.VirtualRolePrincipal'.
↵    
↵
↵    
↵
↵            

Server Error in '/' Application.

↵ ↵

Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'EPiServer.Security.VirtualRolePrincipal'.

↵ ↵ ↵ ↵ Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. ↵ ↵

↵ ↵ Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'EPiServer.Security.VirtualRolePrincipal'.

↵ ↵ Source Error:

↵ ↵ ↵ ↵ ↵ ↵
↵ ↵An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. ↵ ↵
↵ ↵
↵ ↵ Stack Trace:

↵ ↵ ↵ ↵ ↵ ↵
↵
↵[InvalidCastException: Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'EPiServer.Security.VirtualRolePrincipal'.]
↵   EPiServer.Labs.LanguageManager.Controllers.LanguageStore.IsCurrentUserInAdminRole() +36
↵   lambda_method(Closure , ControllerBase , Object[] ) +62
↵   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
↵   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
↵   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
↵   System.Web.Mvc.<>c__DisplayClass15.b__12() +56
↵   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +256
↵   System.Web.Mvc.<>c__DisplayClass17.b__14() +22
↵   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +256
↵   System.Web.Mvc.<>c__DisplayClass17.b__14() +22
↵   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +190
↵   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +522
↵   EPiServer.Shell.Services.Rest.RestControllerBase.ExecuteCore() +175
↵   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +181
↵   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
↵   EPiServer.Shell.Services.Rest.RestHttpHandler.ProcessRequest(HttpContextBase httpContext) +197
↵   EPiServer.Shell.Services.Rest.RestHttpHandler.ProcessRequest(HttpContext context) +42
↵   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
↵   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
↵
↵ ↵
↵ ↵
↵ ↵
↵ ↵ Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.5.22.0 ↵ ↵
↵ ↵ ↵ ↵"stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }status: 500xhr: XMLHttpRequest__proto__: TMPdojo.js:15 _498dojo.js:15 (anonymous function)dojo.js:15 _2cddojo.js:15 _2cbdojo.js:15 reject.errbackdojo.js:15 _2cddojo.js:15 _2cbdojo.js:15 reject.errbackdojo.js:15 (anonymous function)dojo.js:15 _2f2dojo.js:15 _2ecdojo.js:15 _30a.rejectdojo.js:15 _2f8dojo.js:15 _2f2dojo.js:15 _2ecdojo.js:15 _30a.rejectdojo.js:15 _2f8dojo.js:15 _2f2dojo.js:15 _2ecdojo.js:15 _30a.rejectdojo.js:15 _2f8dojo.js:15 _2f2dojo.js:15 _2ecdojo.js:15 _30a.rejectdojo.js:15 _2f8dojo.js:15 _2f2dojo.js:15 _2ecdojo.js:15 _30a.rejectdojo.js:15 _4f2dojo.js:15 _4fe :55930/e635aa06cd254720b61b01108f3d4369/browserLink:37 Setting 'XMLHttpRequest.withCredentials' for synchronous requests is deprecated.
#114361
Dec 10, 2014 21:37

Did the same with webforms. Same error

#114362
Dec 10, 2014 22:07

Added this and it works

<virtualRoles replacePrincipal="true">

#114363
Dec 10, 2014 22:22

Hi,

I think your solution is right to the point.

Root error is show in the log:

[InvalidCastException: Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'EPiServer.Security.VirtualRolePrincipal'.]
EPiServer.Labs.LanguageManager.Controllers.LanguageStore.IsCurrentUserInAdminRole()
The function IsCurrentUserInAdminRole() try to cast (EPiServer.Security.VirtualRolePrincipal)PrincipalInfo.CurrentPrincipal to determine you are admin (in Administrators, WebAdmins group or not).
We will try to improve it in a more elegant way using System.Security.Principal.IPrincipal, if possible.
Thank you.
T.
#114365
Edited, Dec 11, 2014 5:28
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.