Home > OS >  Unable to cast object of type 'ModelDetailView' to type 'DevExpress.ExpressApp.ViewVa
Unable to cast object of type 'ModelDetailView' to type 'DevExpress.ExpressApp.ViewVa

Time:06-12

I installed the View Variants module to my XAF winforms 21.2.7 project and it "works on my machine"

When I deploy and run I get an error with the following call stack logged in eXpressAppFramework.Log

    Type:       InvalidCastException
    Message:    Unable to cast object of type 'ModelDetailView' to type 'DevExpress.ExpressApp.ViewVariantsModule.IModelViewVariants'.
    Data:       0 entries
    Stack trace:
   at DevExpress.ExpressApp.ViewVariantsModule.ModelVariantsProvider.GetVariants(String rootVariantViewId)
   at 

DevExpress.ExpressApp.ViewVariantsModule.ReplaceViewIdHelper.factoryEvents_ViewCreating(Object sender, ViewCreatingEventArgs e)
       at DevExpress.ExpressApp.ViewVariantsModule.XafApplicationViewsFactory.application_ViewCreating(Object sender, ViewCreatingEventArgs e)
       at DevExpress.ExpressApp.XafApplication.OnViewCreating(ViewCreatingEventArgs args)
       at DevExpress.ExpressApp.XafApplication.PrepareDetailViewCreatingEventArgs(IObjectSpace objectSpace, String detailViewID, Boolean isRoot, Object obj, Boolean isDelayedObjectLoading)
       at DevExpress.ExpressApp.XafApplication.CreateDetailViewCore(IObjectSpace objectSpace, String detailViewID, Boolean isRoot, Object obj, Type objectType, Object objectKey, Boolean isDelayedObjectLoading, IEnumerable objectsToPrefetch)
       at DevExpress.ExpressApp.XafApplication.CreateDetailView(IObjectSpace objectSpace, String detailViewID, Boolean isRoot, Object obj, Boolean isDelayedObjectLoading, IEnumerable objectsToPrefetch)
       at DevExpress.ExpressApp.XafApplication.CreateDetailView(IObjectSpace objectSpace, String detailViewID, Boolean isRoot, Object obj)
       at DevExpress.ExpressApp.XafApplication.CreateDetailView(IObjectSpace objectSpace, Object obj, View sourceView)
       at DevExpress.ExpressApp.XafApplication.showLogonAction_OnCustomizePopupWindowParams(Object sender, CustomizePopupWindowParamsEventArgs args)
       at DevExpress.ExpressApp.Actions.PopupWindowShowAction.GetPopupWindowParams()
       at DevExpress.ExpressApp.Win.PopupWindowShowActionHelper.CreatePopupWindow(Boolean createAllControllers)
       at DevExpress.ExpressApp.Win.WinApplication.DoLogon()
       at DevExpress.ExpressApp.Win.WinApplication.Start()
        InnerException is null
    

I can work around the issue by opening a pre-viewvariants copy of the application and logging in.

After that I can use the application successfully.

Alternatively I can delete the file ModulesVersionInfo from the Users Roaming Application folder to get the app opening successfully

Deleting modelassembly.dll from the application folder also solves the issue.

CodePudding user response:

Removing ModelAssembly.Dll from deployment solved the issue. The dll then gets created correctly by the app when it opens.

  • Related