Starcounter/Starcounter.Authorization

Same child view-model can't be used two times in parent view-models

Closed this issue · 2 comments

When We use the same child view-model that represents some part of other view-model more than one time, it will cause Unable to cast object exception.
E.g Exception like this was raised, when VM RoutingItemPage was used in both AllRoutesPage and RoutingPage:

System.InvalidCastException: Unable to cast object of type 'BlendingEditor.Website.ViewModels.RoutingPage' to type 'BlendingEditor.Website.ViewModels.AllRoutesPage'.
   at lambda_method(Closure , RoutingItemPage )
   at lambda_method(Closure , Json , Input`1 )
   at Starcounter.Templates.Property`1.InvokeHandler(Json parent, Input`1 input) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.XSON\Templates\Foundation\Property.cs:line 262
   at Starcounter.Templates.Property`1.ProcessInput(Json parent, T value) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.XSON\Templates\Foundation\Property.cs:line 284
   at Starcounter.XSON.JsonPatch.DefaultPatchHandler.ParseAndProcess(TBool property, Json parent, String valueStr) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.XSON\Sessions\JSON-Patch\DefaultPatchHandler.cs:line 74
   at Starcounter.Internal.TransactionManager.Scope(TransactionHandle handle, Action action) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter\TransactionManager.cs:line 552
   at Starcounter.Transaction.Scope(Action action) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter\Transaction.cs:line 225
   at Starcounter.Advanced.XSON.JsonExtension.Scope(Json json, Action action) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.XSON\Advanced\JsonExtension.cs:line 69
   at Starcounter.XSON.JsonPatch.DefaultPatchHandler.Handle(Json root, JsonPatchOperation patchOp, JsonPointer pointer, String value) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.XSON\Sessions\JSON-Patch\DefaultPatchHandler.cs:line 38
   at Starcounter.XSON.JsonPatch.JsonPatch.HandleOnePatch(Json root, JsonPatchOperation op, JsonPointer ptr, String value, Int32 patchCount, ChangeLog changeLog, Object sourceJson, Boolean strictRejection, JsonPatchStatus previousStatus) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.XSON\Sessions\JSON-Patch\JsonPatch.cs:line 599
   at Starcounter.XSON.JsonPatch.JsonPatch.Apply(Json root, JsonTextReader reader, Boolean strictPatchRejection, Object sourceJson, Int32& patchCount) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.XSON\Sessions\JSON-Patch\JsonPatch.cs:line 493
   at Starcounter.XSON.JsonPatch.JsonPatch.Apply(Json root, String patch, Boolean strictPatchRejection, Int32& patchCount) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.XSON\Sessions\JSON-Patch\JsonPatch.cs:line 414
   at Starcounter.Internal.PuppetRestHandler.HandleWebSocketJson(String bs, WebSocket ws) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.Apps.JsonPatch\BuiltInRestHandlers\PuppetRestHandler.cs:line 73
   at Starcounter.Internal.AllWsGroups.RunHandler(UInt16 managedHandlerId, UInt32 groupId, WebSocket ws) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter.Internal\Http\WsManager.cs:line 290
   at Starcounter.GatewayHandlers.HandleWebSocket(UInt16 managedHandlerId, Byte* rawChunk, BMX_TASK_INFO* taskInfo, Boolean* isHandled) in C:\TeamCity\BuildAgent\work\sc-12991\Level1\src\Starcounter\Apps\GatewayHandlers.cs:line 795
HResult=-2147467262

Related to https://github.com/Starcounter/Blending/issues/31#issuecomment-356945291

This has been fixed in 3.7.2