Calcium and Self-Tracking Entities

Apr 2, 2010 at 1:44 AM

Hi,
I am new to Calcium, and I think it is an awesome toolset.  But I am desparately in need of an example of how to use a business object with a Calcium module.

I am attempting a module for UI for the .NET 4 Entity Framework self-tracking entities. The service reference for the webservice is linked in. A library containing the self-tracking objects is referenced in the module. I have property wrappers setup in the ViewModel for the self-tracking entity's properties.  I have the ViewModel properties bound in the xaml. All this seems to work, in the sense that when I run my Calcium shell my module comes up and I can enter values in the form. 

Now I am stuck on how to get my business objects into the ViewModel. When I put  property on the view model to expose the internal business object, The module fails at runtime in the InitializeComponent() method of the ModuleView. Here is the error message:

An exception of type 'System.Windows.Markup.XamlParseException'
 occurred in PresentationFramework.dll but was not handled in user code

Additional information: 'The invocation of the constructor on type
'MethodClient.MethodModule.MethodViewModel' that matches the specified
binding constraints threw an exception.' Line number '11' and line position '6'.

Then the shell says my module faied to load and has been disabled.  I hope somebody here can get me to the next step or point me to a module sample using a business object.

Thanks for the help,

Tim Bailey

Coordinator
Apr 4, 2010 at 1:02 PM

Hi Tim,

Did you find anything when stepping through the MethodViewModel constructor?

Apr 5, 2010 at 7:17 PM

Hi Daniel,

In stepping through the code, I don't ever get to the constructor for the MethodViewModel. The error occurs in loading MethodView.xaml, apparently at: 
<Gui:ViewControl.ViewModel>
   
<Module:MethodViewModel /> 
</Gui:ViewControl.ViewModel>

The inner exception is:
"Could not load file or assembly 'MethodEntities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
I think it must be a dependency, because the reference is there and the compiler doesn't complain about the declaration.

MethodEntities is a class library containing the POCO classes  (including Method) generated by the self-tracking entities T4 template. The library worked as expected when I tested my service in a console application. I set the references on the Calcium module the same as on the console application (as close as I can tell). Clearly, I don't have MethodEntities wired up right for this application. The MethodEntities classes support the INotifyPropertyChanged interface.

 At this point, the MethodViewModel is very minimalist. Without the Method getter/setter, I get a compiler warning that _method is never assigned to and will always be null. With the getter/setter or any  other mechanism that actually would allow giving _method a value, the error occurs.


    public class MethodViewModel : ViewModelBase
    {
        private Method _method;

        public MethodViewModel()
        {
            Title = "Method Module";
        }

        public Method Method { get { return _method; } set { _method = value; } }

        public string OfficialName { get { return _method.OfficialName;} set { _method.OfficialName = value;} }

        public string MethodNumber { get { return _method.MethodNumber; } set { _method.MethodNumber = value; } }

    }


 Any help will be gratly appreciated. Thank you,

Tim

Coordinator
Apr 5, 2010 at 8:03 PM

Tim,

Have you tried using fuslogvw to locate the missing dependent assembly?

 

Apr 5, 2010 at 11:47 PM

Hi Daniel,

Thanks for the help. I had never heard of fuslogvw. It is very useful.

I discovered that I needed a reference for System.RunTime.Serialization in my Calcium project assembly for using my MethodEntities library.

My self-tracking entity objects are loading correctly.  Fuslogvw is still showing a binding failure for something called 'System.XmlSerializers'

Thanks again
Tim