CSLA Tools Components

CSLA Tools Components

Old forum URL: forums.lhotka.net/forums/t/10723.aspx


skumarsamy posted on Thursday, September 29, 2011

Hi, Need help on getting the CSLA Tools to add to my visual studio 2010, where should i get these.

thanks

kumar

Russ replied on Thursday, September 29, 2011

Hi Kumar,

Here are the steps:

  1. Right click in the toolbox area in VS2010 and select "Add Tab"
  2. Name the tab "CSLA".
  3. Open Windows Explorer and navigate to the folder "C:\Program Files (x86)\Marimer LLC\CSLA .NET\4.1.0\Bin\Release\Silverlight"
  4. Drag the "Csla.Xaml.dll" into the toolbox area in VS2010

JonnyBee replied on Thursday, September 29, 2011

Hi,

Another option is to subclass the CSLA components in your own solution.
This is recommended for both intermediate base classes and controls and will provide extension points for these in your project.

You'll love it when you are switching between solutions that use different versions of CSLA. Having different versions of CSLA in the toolbox and solution can be awkward and give you strange exceptions.

Visual Studio will automatically load controls in your source projects into the Toolbox.

skumarsamy replied on Sunday, October 02, 2011

Hi,

will you please give me some idea how to havve an intermediate class to extend the components

thanks

 

Russ replied on Thursday, October 06, 2011

Hi Jonny,

 

I just ran into the strange exceptions that you predicted when working on projects with different CSLA versions. I tried to implement your suggestions and I am getting an error that I hope you can help me with.  Here’s what I have so far.

 

I created the following wrapper class for the csla Xaml classes.

 

namespace Admin.CslaControls

{

  public class BusyAnimation : Csla.Xaml.BusyAnimation

  {

   public BusyAnimation() : base() { }

  }

 

  public class ErrorDialog : Csla.Xaml.ErrorDialog

  {

   public ErrorDialog() : base() { }

  }

 

  public class PropertyInfo : Csla.Xaml.PropertyInfo

  {

   public PropertyInfo() : base() { }

   public PropertyInfo(bool testing) : base(testing) { }

  }

 

  public class PropertyStatus : Csla.Xaml.PropertyStatus

  {

   public PropertyStatus() : base() { }

  }

 

  public class TriggerAction : Csla.Xaml.TriggerAction

  {

   public TriggerAction() : base() { }

  }

 

  // depreciated classes

  public class CslaDataProvider : Csla.Xaml.CslaDataProvider

  {

   public CslaDataProvider() : base() { }

  }

 

  public class InvokeMethod : Csla.Xaml.InvokeMethod

  {

   public InvokeMethod(UIElement ctrl) : base(ctrl) { }

  }

}

 

Then I replaced the xmlns:csla="clr-namespace:Csla.Xaml;assembly=Csla.Xaml"

with my wrapper xmlns:csla="clr-namespace:Admin.CslaControls"

in the <UserControl> tag of one of the views.

 

The xaml code seems happy but the designer will not load due to an unhandled exception as follows:

 

System.ArgumentException

GenericArguments[0], 'T', on 'Csla.DataPortalClient.WcfProxy`1[T]' violates the constraint of type 'T'.

   at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)   at System.RuntimeType.MakeGenericType(Type[] instantiation)   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.GetRuntimeType(Type type)   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkType.TryGetRuntimeType()   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.EnsureRuntimeType(Type type)   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider.GetRuntimeType(Type reflectionType)   at MS.Internal.Package.VSIsolationProviderService.RemoteReferenceProxy.VsReflectionResolver.GetRuntimeType(Type reflectionType)   at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.CachingReflectionResolver.GetRuntimeType(Type reflectionType)   at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.Microsoft.Windows.Design.Metadata.IReflectionResolver.GetRuntimeType(Type reflectionType)   at MS.Internal.Metadata.ClrType.get_RuntimeMember()   at MS.Internal.Metadata.ClrMember`1.Microsoft.Windows.Design.Metadata.Reflection.IReflectionMember.get_MemberInfo()   at MS.Internal.Metadata.ClrType.Equals(Object obj)   at System.Collections.Generic.ObjectEqualityComparer`1.Equals(T x, T y)   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)   at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.XamlMemberFor[TMember,TXaml](TMember member, Factory`2 factory)   at MS.Internal.Design.Metadata.Xaml.XamlType.<GetAllAttachableProperties>d__7.MoveNext()   at MS.Internal.Design.Metadata.Xaml.XamlType.<FindAttachableProperties>d__0.MoveNext()   at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.<FindAttachableProperties>d__7.MoveNext()   at MS.Internal.VirtualModel.VirtualModelPropertyCollection.<GetUncachedProperties>d__0.MoveNext()   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)   at MS.Internal.VirtualModel.VirtualModelPropertyCollection.GetEnumerator()   at MS.Internal.VirtualModel.VirtualModelUtilities.WrapProperties(IVirtualModelItem item)   at MS.Internal.VirtualModel.VirtualModelItem.System.ComponentModel.ICustomTypeDescriptor.GetProperties()   at System.ComponentModel.TypeDescriptor.MergedTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()   at System.ComponentModel.TypeDescriptor.GetPropertiesImpl(Object component, Attribute[] attributes, Boolean noCustomTypeDesc, Boolean noAttributes)   at System.Windows.PropertyPath.ResolvePropertyName(String name, Object item, Type ownerType, Object context, Boolean throwOnError)   at MS.Internal.Data.PropertyPathWorker.GetInfo(Int32 k, Object item, SourceValueState& svs)   at MS.Internal.Data.PropertyPathWorker.ReplaceItem(Int32 k, Object newO, Object parent)   at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)   at MS.Internal.Data.ClrBindingWorker.AttachDataItem()   at System.Windows.Data.BindingExpression.Activate(Object item)   at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)   at System.Windows.Data.BindingExpression.AttachOverride(DependencyObject target, DependencyProperty dp)   at System.Windows.Data.MultiBindingExpression.AttachBindingBLOCKED EXPRESSION

I would appreciate any suggestions you might have.

 

Thanks

Russ.

 

JonnyBee replied on Friday, October 07, 2011

Hmm,

I'd recommend to have the base classes and controls in a separate assembly  that should/must always exist.

Cider (the Xaml designer) will actually load and run your code in the designer.

Initial thoughts is that this is a data binding problem (AttachBinding) in connection with the WCF Proxy.

Could it be that the namespace edit is not sufficient.

I tried this on the ProjectTracker WPF sample and the designer works fine after the changes.

 

Russ replied on Friday, October 07, 2011

Thanks for the reply Jonny,

I'm confused.  If the base classes and controls have to be in a separate assembly that needs to be referenced from the main project then why not just reference CSLA.Xaml.DLL directly?

JonnyBee replied on Friday, October 07, 2011

When the code is  in your solution then Visual Studio will automatically add these controls to the tools window and it will also allow you to extend / add functionality to the CSLA base classes.

You could however also add Csla.Xaml project to your solution.

What you should be aware of is that XAML Designer ("Cider") actually runs YOUR code in the designer.
So if the designer is unable to load the controls (ie: the assembly doesn't compile) you will experience problems in the designer.

Just my personal preference to keep the extension in its own assembly as this also allows me to create my own template project for the base classes.

 

 

 

 

Copyright (c) Marimer LLC