I'm using the preview 4 of Csla 4.0 so possibly that's the cause? The strange thing here is that the solution compiles but this error actually occurs prior to the instantiation of an inherited criteria class at runtime. Simply having a var x = new MyCriteria line causes the exception to be thrown the second the CLR hits the method that contains that line but PRIOR to actually hitting the line of code itself.
Can you provide the full stack trace (yourException.ToString())? That might help identify the specific issue.
I have numerous unit tests and other apps that use criteria objects, so it isn't an obvious problem.
Unfortunately there isn't really anything in the stack trace.
System.TypeLoadException: Could not load type 'Csla.CriteriaBase`1' from assembly 'Csla, Version=4.0.0.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30'.
at BootStrap.Program.ReadMyList()
at BootStrap.Program.Main(String[] args)
The oddest part here for me is how the exception occurs because of the instantiation of the criteria object but occurs before the line that instantiates it.
BaseCriteria was made a generic type in 4.0, can you provide a snippit of code as an example of derived criteria in 4.0? Maybe there's something there.
CriteriaBase was made generic so you can use the same property declaration structure (with managed backing fields, etc) as ReadOnlyBase. This makes it much simpler to build Silverlight apps that need complex criteria.
Also in CSLA 4 you don't really need any formal criteria object for simple criteria values (like string, int, Guid, etc). Any serializable type is allowed as criteria without being wrapped in a formal criteria class.
This means the only time you should need to create an actual criteria class of your own is when your criteria involves more than one field of data.
Yes, I have a couple such criteria. Originally these criteria were defined as such
public class FooCriteria : CriteriaBase
After I updated to CSLA 4 preview 4 assemblies I updated the class definition to
public class FooCriteria : CriteriaBase<FooCriteria>
Everything compiles. Whenever I instantiate FooCriteria the exception in question is thrown. The fact that this exception is thrown prior to the actual new FooCriteria line has me mystified as well.
Aaaarrrrrggggg!!!! I had a reference problem in the project in question.
Here is a Stack Trace that i got when trying to create my object
When traced i saw that the exception is causing when the UI bounds the data-source to the business layer
here you go
at TestApp.Form1.NavBarItem1_LinkClicked(Object sender, NavBarLinkEventArgs e)
at DevExpress.XtraNavBar.NavBarItem.RaiseLinkEvent(Object linkEvent, NavBarItemLink link)
at DevExpress.XtraNavBar.NavBarItem.RaiseLinkClicked(NavBarItemLink link)
at DevExpress.XtraNavBar.NavBarItem.RaiseLinkClickedCore(NavBarItemLink link)
at DevExpress.XtraNavBar.NavBarControl.RaiseLinkClicked(NavBarItemLink link)
at DevExpress.XtraNavBar.ViewInfo.NavBarViewInfo.DoLinkClick(NavBarHitInfo hitInfo)
at DevExpress.XtraNavBar.ViewInfo.NavBarViewInfo.DoClick(NavBarHitInfo hitInfo)
at DevExpress.XtraNavBar.ViewInfo.NavBarViewInfo.OnMouseUp(MouseEventArgs e)
at DevExpress.XtraNavBar.NavBarControl.OnMouseUp(MouseEventArgs ev)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at DevExpress.XtraNavBar.NavBarControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at TestApp.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Copyright (c) Marimer LLC