當嘗試在ListView中顯示NonPersistent Obejct時,會報告objectKeyAsString參數為null,顯示一個紅色大叉。
查看輸出如下:
15.05.12 10:50:47.201 ->GetPopupWindowParams
15.05.12 10:50:47.202 Type: DevExpress.ExpressApp.Actions.PopupWindowShowAction
15.05.12 10:50:47.203 ID: b97c96de-e2e9-4132-a5e7-46d384838773
15.05.12 10:50:47.204 Category: Unspecified
15.05.12 10:50:47.205 ContextName: User
15.05.12 10:50:47.206 IsRoot: True
15.05.12 10:50:47.207 Selection.Count: 1
15.05.12 10:50:47.208 CurrentObject: DevExpress.ExpressApp.Security.SecuritySimpleUser(544f6a52-9f48-48e2-bdf0-0b5b6025c63d)
15.05.12 10:50:47.274 --------------------------------------------------------------------------------
15.05.12 10:50:47.275 <- GetPopupWindowParams
15.05.12 10:50:48.389 ================================================================================
The error occurred:
Type: ArgumentNullException
Message: 值不能為 null。
參數名: objectKeyAsString
Data: 0 entries
Stack trace:
在 DevExpress.ExpressApp.ObjectHandleHelper.CreateObjectHandle(ITypesInfo typesInfo, Type objectType, String objectKeyAsString)
在 DevExpress.ExpressApp.ObjectSpace.GetObjectHandle(Object obj)
在 DevExpress.ExpressApp.Security.MemberOperationPermissionRequest..ctor(Object targetObject, String memberName, String operation)
在 DevExpress.ExpressApp.DataManipulationRight.HasPermissionTo(Type objectType, String memberName, Object targetObject, CollectionSourceBase collectionSource, String operation)
在 DevExpress.ExpressApp.DataManipulationRight.CanRead(Type objectType, String propertyName, Object targetObject, CollectionSourceBase collectionSource)
在 DevExpress.ExpressApp.Win.Editors.GridListEditor.gridView_CustomDrawCell(Object sender, RowCellCustomDrawEventArgs e)
在 DevExpress.XtraGrid.Views.Grid.GridView.RaiseCustomDrawCell(RowCellCustomDrawEventArgs e)
在 DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRowCell(GridViewDrawArgs e, GridCellInfo cell)
在 DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRegularRowCell(GridViewDrawArgs e, GridCellInfo ci)
在 DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRegularRow(GridViewDrawArgs e, GridDataRowInfo ri)
在 DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRow(GridViewDrawArgs e, GridRowInfo ri)
在 DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRows(GridViewDrawArgs e)
在 DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawContents(GridViewDrawArgs e)
在 DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.Draw(ViewDrawArgs ee)
在 DevExpress.XtraGrid.Views.Base.BaseView.Draw(GraphicsCache e)
在 DevExpress.XtraGrid.GridControl.OnPaint(PaintEventArgs e)
在 System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
在 System.Windows.Forms.Control.WmPaint(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 DevExpress.XtraEditors.Container.EditorContainer.WndProc(Message& m)
在 DevExpress.XtraGrid.GridControl.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException is null
從上面的輸出可以看到,是XAF的安全機制導致的結果,所以,我嘗試,將工程的安全性原則取消,果然不再報錯。但一個Bussiness Software不可能沒有安全機制,若為了使用Nonpersistent Object而去掉內建的安全機制無疑是挖肉補瘡。
這是官網上給出的解釋,說明是安全機制的緣故,也印證了我的猜想。目前,只好不在View中顯示NonPersistent Object
後註:已解決,見我下一篇博文。