CSLA .NET Contrib News Feed 
Monday, June 15, 2015  |  From CSLA .NET Contrib

This forum is now an archive.


All active discussions can be found on the CSLA Forum on GitHub.


 


----


This forum is now read-only and new user registration is disallowed.


To use the new forum you will need to create a GitHub account. There is no cost to such an account.

Friday, June 12, 2015  |  From CSLA .NET Contrib

I am fairly new to CSLA4 and in general I have had no issues working with it until I tried to create Fetch method that passed a Nullable<Boolean> value. I can pass either 'true' or 'false' however if I pass in 'null', I get a DataPortal Exception.


An unhandled exception of type 'Csla.DataPortalException' occurred in Csla.dll


Additional information: DataPortal.Fetch failed (Invalid operation - fetch not allowed)


It seems reasonable to be able to do this.


Is this a bug or simply just not supported? - Why not?

Wednesday, June 10, 2015  |  From CSLA .NET Contrib

I am bringing my mature SL app to WPF. I am quite liberal with the use of AutoCompleteBoxes and often have more than one on a page.


The data for the dropdown of each Auto...box comes from a database table.  Instead of running to the Database for each Auto..box's list, I bring up the list for the whole page, and then use a subset of that list when the user navigates to a given Auto...box.  All my lists are of the MobileList kind.  This has worked fine in SL. (The same is happening with BusinessListBase)



In WPF the behavior is strange.  The lists do appear in the dropdown, but when I choose an item with mouse the selection immediately disappears and the box remains empty.  When I make the selection by using the up-down arrow keys on the keyboard, the selection behaves normally.



Now here is the interesting part.  If, instead of displaying the subset (Path = FilteredList), I use the entire list (Path = Model), everything works fine.  The workaround I have used on one instance of AutoCompleteBox is to create another class specifically to hold the selected subset.  Using that I can set the Path = Model, and with that things appear to work.  With the number Auto..boxses, making the change to all is, well, daunting.
So I thought I should ask if there is a simpler solution for this. 


I'll appreciate any suggestions.


Javed

Wednesday, June 10, 2015  |  From CSLA .NET Contrib

Yes, that's true. But don't want to set the bar too high.

Opened the Csla.winrt solution. Created a new project of type "Empty Class Library (C#/XAML for HTML5) named Csla.CSHTML5. Changed the namespace to "Csla" Added conditional symbol SILVERLIGHT. Copied all the files and linked files from Csla.Silverlight project by editing the Csla.CSHTML5.csproj in a text editor.

Ended up with errors as expected. A lot of them them ambiguous reference between 'System.NonSerializedAttribute' and 'Csla.Serialization.NonSerializedAttribute' and between 'System.SerializableAttribute' and 'Csla.Serialization.SerializableAttribute'. That I don't know how to get rid of.

Browsing the project looking at the using statements I can see that these are missing:
using System.ComponentModel.DataAnnotations;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Xml.Linq;

Also I noticed that IEditableObject, INotifyDataErrorInfo, INotifyPropertyChanging, System.ComponentModel.BackgroundWorker, DoWorkEventHandler, RunWorkerCompletedEventHandler, ProgressChangedEventHandler, System.ComponentModel.AsyncCompletedEventArgs, XmlDictionaryReader, DataContractSerializer, LinkedList
 was missing.


 


Wilfred

Tuesday, June 9, 2015  |  From CSLA .NET Contrib

I am looking at the possibility of moving this forum to GitHub.


GitHub isn't really _designed_ to be a forum, but the issues list for a project provides threaded conversations that I think can replace the functionality that we're using here on this forum, but with a much more modern user interface and experience.



https://github.com/MarimerLLC/cslaforum/issues


The above URL is the site I've set up for this - please take a look, try it out, and let me know what you think.


One way or another, this current forum needs to be replaced, as its software is no longer maintained and it will eventually just fail out from under us.



 

Monday, June 8, 2015  |  From CSLA .NET Contrib

We're having a problem introducing connection manager to our existing application.  While root objects usually share the SqlConnection with their children, there are a lot of places where other BOs get involved, which end up opening their own connection.  We've introduced ConnectionManager in another application successfully and this resolved the connection pool being exhausted (it was already set to 500) and seemed to improve performance a bit too.


However we're having trouble in our main app, which has a much larger user base.  I think we've narrowed the issue to some BOs which are used by the client to get updated information frequently, approximately every minute or so.


The issue seems to be that sometimes under high load, the Asp.Net AppPool hosting the remoting (yes, remoting) site hangs.  New remoting connections are accepted, but stay forever at waiting for response, and everything just stops.  The only solution is doing an IISRESET, which hard kills the w3p.exe process hosting the remoting site (it doesn't response to a normal recycle either, although IIS still thinks things are fine). 


I've had a look at the Csla code, and I see its doing some locking which is necessary on 2-tier apps but probably less relevant for hosting under Asp.net.  I've seen the thread around that here too so I think its unlikely to be our issue.  I'm wondering if somehow async / await in combination with ConnectionManager is causing connections not to be returned to the pool (we have some errors logged indicating this).


Anyone else encountered this?

Friday, June 5, 2015  |  From CSLA .NET Contrib

Hi all ,


currently i used csla ver 4.3.12 in c#. but recently I got a small project which need vb.net as language


so, i need a easy migration from my c# syntax into vb.net ?


 


could anyone give a suggestion ?


public static readonly PropertyInfo<string> InvNoProperty =
            RegisterProperty<string>(t => t.InvoiceNo);
        public string InvoiceNo
        {
            get { return GetProperty(InvNoProperty); }
            private set { LoadProperty(InvNoProperty, value); }
        }


into a vb.net ????


 


thanks


stefanus


 

Friday, June 5, 2015  |  From CSLA .NET Contrib

Does anyone still use the msi installer for CSLA?


These days I just assume everything of value is in NuGet, and my primary focus with CSLA releases has been NuGet for the past couple years.


I do still maintain the msi installer, but it is kind of a PITA, especially if nobody uses it.


My train of thought is that anyone who wants the samples, source code, and other artifacts can just as easily pull the zip archive that GitHub automatically creates for each CSLA release.


What do you all think? Keep or drop the msi installer project?

Thursday, June 4, 2015  |  From CSLA .NET Contrib

I've put an early prerelease of version 4.6 on NuGet. Details are here:



https://github.com/MarimerLLC/csla/releases/tag/v4.6.001


The primary change (and point of risk) is that I consolidated nearly all the code files into a set of shared projects, adding some compiler directives to address any outstanding conflicts between the old duplicate code files.


The upside of this is that maintenance of CSLA will now be much easier, as will adding support for new platforms or version of .NET over time.


The downside is that I may have introduced bugs if I got some of the compiler directives wrong - especially likely in the Android and iOS code (the areas most affected by the duplicate code).


If you find any issues please add issues to GitHub with details on what you encounter - thanks!


https://github.com/MarimerLLC/csla/issues



 


Friday, May 29, 2015  |  From CSLA .NET Contrib

Hello,


Thank you in advance for any help provided here.  I read the answers on this post and still have a problem with my custom Principal/Identity implementation.


I am using Csla 4.1.0 and seem to be having a cast issue.  This is the same scenario as the OP in the linked thread where I am trying to get to custom properties that have been implemented into my CustomIdentity class.


When I try to cast Csla.ApplicationContext.User.Identity to CustomIdentity, I get "Unable to cast object of type 'System.Security.Principal.GenericPrincipal' to 'DMS.Library.Security.CustomIdentity.'


Here's the code in question:


public int UserOrgCount {


            get {


                var identity = (CustomIdentity)Csla.ApplicationContext.User.Identity;


                return identity.Orgs.Count();


            }


        }


I thought I followed the ebook pretty well and in fact everything seems to be working.  The only thing I want to get access to now is the Identity properties so that I can replace individual database calls with data that's already been loaded into my custom properties.


Let me know if there is any other information I can provide.


For reference, here is my CustomPrincipal and CustomIdentity objects:


 


using System;


using System.Security.Principal;


using Csla.Security;


using Csla.Serialization;


 


namespace DMS.Library.Security {


    [Serializable]


    public class CustomPrincipal : CslaPrincipal {


        private CustomPrincipal(IIdentity identity)


            : base(identity) { }


 


        /// <summary>


        /// 


        /// </summary>


        /// <param name="username">The user's username</param>


        /// <param name="password">The user's password</param>


        /// <param name="completed"></param>


        public static void BeginLogin(string username, string password, Action<Exception> completed) {


            DMS.Library.Security.CustomIdentity.GetCustomIdentity(username, password, (o, e) => {


                if (e.Error != null)


                    Logout();


                else


                    Csla.ApplicationContext.User = new CustomPrincipal(e.Object);


                completed(e.Error);


            });


        }


 


#if !SILVERLIGHT


 


        /// <summary>


        /// NOT IMPLEMENTED - Attempts to login the user with their username and password


        /// </summary>


        /// <param name="pUserName">The user's username</param>


        /// <param name="pPassword">The user's password</param>


        /// <remarks>


        /// As of 05/07/2015, this function is not used because it will create a circular execution of code.  


        /// Validation of credentials is handled within the ValidateUser function of each implemented Membership provider.


        /// Assuming the ValidateUser function returns true, the Principal's Load function is used instead


        /// </remarks>


        public static void Login(string username, string password) {


            throw new NotImplementedException("The CustomPrincipal Login method has not been implemented.  Refer to the remarks section of method's code for an explanation.");


            //var identity = DMS.Library.Security.CustomIdentity.GetCustomIdentity(username, password);


            //Csla.ApplicationContext.User = new CustomPrincipal(identity);


        }


 


        public static void Load(string username) {


            var identity = DMS.Library.Security.CustomIdentity.GetCustomIdentity(username);


            Csla.ApplicationContext.User = new CustomPrincipal(identity);


        }


 


#endif


 


        /// <summary>


        /// Replaces the current CustomPrincipal object with a new one that has an UnauthenticatedIdentity loaded up.


        /// </summary>


        public static void Logout() {


            Csla.ApplicationContext.User = new UnauthenticatedPrincipal();


        }


    }


}




using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Csla;

using Csla.Security;

using Csla.Serialization;

using DMS.Library.Admin;


namespace DMS.Library.Security {

    [Serializable]

    public class CustomIdentity : CslaIdentityBase<CustomIdentity> {

        

        #region Properties


            public static readonly PropertyInfo<string> EmailProperty = RegisterProperty<string>(c => c.Email);

            /// <summary>

            /// The user's E-mail

            /// </summary>

            public string Email {

                get { return GetProperty(EmailProperty); }

                private set { LoadProperty(EmailProperty, value); }

            }


            public static readonly PropertyInfo<Guid> UserIdProperty = RegisterProperty<Guid>(p => p.UserId);

            /// <summary>

            /// The user's internal identifier

            /// </summary>

            public Guid UserId {

                get { return GetProperty(UserIdProperty); }

                private set { LoadProperty(UserIdProperty, value); }

            }


            public static readonly PropertyInfo<string> FirstNameProperty = RegisterProperty<string>(c => c.FirstName);

            /// <summary>

            /// The user's first name

            /// </summary>

            public string FirstName {

                get { return GetProperty(FirstNameProperty); }

                private set { LoadProperty(FirstNameProperty, value); }

            }


            public static readonly PropertyInfo<string> LastNameProperty = RegisterProperty<string>(c => c.LastName);

            /// <summary>

            /// The user's last name

            /// </summary>

            public string LastName {

                get { return GetProperty(LastNameProperty); }

                private set { LoadProperty(LastNameProperty, value); }

            }


            public static readonly PropertyInfo<string> FullNameProperty = RegisterProperty<string>(c => c.FullName);

            /// <summary>

            /// The user's full name

            /// </summary>

            public string FullName {

                get { return GetProperty(FullNameProperty); }

                private set { LoadProperty(FullNameProperty, value); }

            }


            public static readonly PropertyInfo<string> HomeOrgStringProperty = RegisterProperty<string>(p => p.HomeOrgString);

            /// <summary>

            /// The user's Home OrgString

            /// </summary>

            public string HomeOrgString {

                get { return GetProperty(HomeOrgStringProperty); }

                private set { LoadProperty(HomeOrgStringProperty, value); }

            }


            public static readonly PropertyInfo<bool> IsApprovedProperty = RegisterProperty<bool>(p => p.IsApproved);

            /// <summary>

            /// The original membership IsApproved column

            /// </summary>

            /// <remarks>

            /// Value comes from the aspnet_Membership tables

            /// </remarks>

            public bool IsApproved {

                get { return GetProperty(IsApprovedProperty); }

                private set { LoadProperty(IsApprovedProperty, value); }

            }


            public static readonly PropertyInfo<List<string>> OrgsProperty = RegisterProperty<List<string>>(p => p.Orgs);

            /// <summary>

            /// Returns the list of Departments that the user belongs to

            /// </summary>

            public List<string> Orgs {

                get { return GetProperty(OrgsProperty); }

                private set { LoadProperty(OrgsProperty, value); }

            }


            public static readonly PropertyInfo<string> AppNameProperty = RegisterProperty<string>(p => p.AppName);

            public string AppName {

                get { return "AppName"; }

            }


    #endregion


        public static void GetCustomIdentity(string username, string password, EventHandler<DataPortalResult<CustomIdentity>> callback) {

            DataPortal.BeginFetch<CustomIdentity>(new UsernameCriteria(username, password), callback);

        }


#if !SILVERLIGHT


        /// <summary>

        /// Gets the user after authenticating them with their username and password

        /// </summary>

        /// <param name="pUserName">The user's employee number</param>

        /// <param name="pPassword">The user's password</param>

        /// <returns></returns>

        public static CustomIdentity GetCustomIdentity(string username, string password) {

            return DataPortal.Fetch<CustomIdentity>(new UsernameCriteria(username, password));

        }

        

        private void DataPortal_Fetch(UsernameCriteria criteria) {

            AuthenticationType = "Custom";

            using (var mgr = DataAccess.DalFactory.GetManager()) {

                var dal = mgr.GetProvider<DataAccess.IIdentityDal>();

                if (dal.VerifyUser(criteria.Username, criteria.Password))

                    LoadUserData(criteria.Username, dal);

            }

        }


        /// <summary>

        /// Gets the user based on their username

        /// </summary>

        /// <param name="pUserName">The user's employee number</param>

        /// <returns></returns>

        internal static CustomIdentity GetCustomIdentity(string username) {

            return DataPortal.Fetch<CustomIdentity>(username);

        }


        private void DataPortal_Fetch(string username) {

            AuthenticationType = "Custom";

            using (var mgr = DataAccess.DalFactory.GetManager()) {

                var dal = mgr.GetProvider<DataAccess.IIdentityDal>();

                LoadUserData(username, dal);

            }

        }


        /// <summary>

        /// Uses the DataAccess DalFactory to dynamically load the required membership provider

        /// </summary>

        /// <param name="pUserName">The user's employee number</param>

        /// <param name="dal">The Identity's data access object</param>

        private void LoadUserData(string pUserName, DataAccess.IIdentityDal dal) {

            var userData = dal.GetUser(pUserName);

            //Step 1 authentication loading - If the user exists in the membership tables, the user is temporarily authenticated

            this.IsAuthenticated = (userData != null);

            

            if (this.IsAuthenticated) {


                this.Name = userData.UserName;

                this.FirstName = userData.FirstName;

                this.LastName = userData.LastName;

                this.FullName = string.Format("{0} {1}", userData.FirstName, userData.LastName);

                this.Email = userData.Email;

                this.UserId = userData.UserId;

                this.HomeOrgString = userData.HomeOrgString;

                this.IsApproved = userData.IsApproved;


                //Step 2 authentication loading - Update the Identity's IsAuthenticated property based on the membership table

                this.IsAuthenticated = this.IsApproved;


                //Initialize the MobileList property and then load up the roles once we've gotten them

                this.Roles = new Csla.Core.MobileList<string>();

                string[] _roles = UserRole.GetRolesForUser(pUserName, string.Empty, true);

                foreach (var role in _roles) {

                    this.Roles.Add(role);

                }


                //Load up the Orgs the user belongs to

                this.Orgs = UserOrg.GetOrgsForUser(pUserName, true, false).ToList();


                //Step 3 authentication loading - Check to make sure that even if the user is authenticated with AD and exists in the membership table, the user has at least 1 Org and Role

                if (!(this.Orgs.Count() > 0 && this.Roles.Count() > 0)) {

                    this.IsAuthenticated = false;

                    throw new InvalidOperationException(string.Format("User {0} does not have access to any departments and/or roles.\n    Org Count: {1};\n    Role Count: {2}", this.Name, this.Orgs.Count(), this.Roles.Count()));

                }

            }

        }


#endif


    }

}

Thursday, May 28, 2015  |  From CSLA .NET Contrib

Hi All,


In my WPF project with CSLA v 4.70, I configured mobileProxy same with Project tracker .


However, when I try to fetch some simple readonly list, Dataportal_fetch has never been touched.


On debugging, error was fired at following line of fetch method of mobileproxy.cs.


#if !NET40
          response = await proxy.FetchAsync(request).ConfigureAwait(false);
#else


and  stack trace shows


Csla.DataPortalClient.MobileProxy.<Fetch>d__8.MoveNext() file d:\DotNetApps\CNS\Source\Business\Csla\Csla\DataPortalClient\MobileProxy.cs:line 327


and inner error message says ' returned internal server error 500..'


I tried both calling method of  async and callback fetch, but had same error.


   CNS.Business.Entity.LineProcessInfoList.GetLineProcessInfoList(new Business.Entity.LineProcessCriteria(true, 1), (o, args) =>
            {
                if (args.Error == null)
                    lines = args.Object;
            });


 var list = await CNS.Business.Entity.LineProcessInfoList.GetLineProcessInfoListAsync(new Business.Entity.LineProcessCriteria(true, 1));


Pls give me any advise what I missed or share your experience. Following is each config.


app.config


  <appSettings>
    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.MobileProxy, Csla"/>
    <add key="CslaDataPortalUrl" value="http://localhost:3969/slPortal.svc"/>
  </appSettings>


web.config


 <appSettings>
    <add key="CslaAuthentication" value="Csla" />
  </appSettings>
  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service name="Csla.Server.Hosts.WcfPortal" behaviorConfiguration="returnFaults">
        <endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IWcfPortal"
                  contract="Csla.Server.Hosts.IWcfPortal" />
      </service>
      <service name="Csla.Server.Hosts.Mobile.WcfPortal" behaviorConfiguration="returnFaults">
        <endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IWcfPortal"
                  contract="Csla.Server.Hosts.Mobile.IWcfPortal" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"
                 maxBufferSize="2147483647">
          <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
                        maxNameTableCharCount="2147483647" maxDepth="2147483647" />
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="wsHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647">
          <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
                        maxNameTableCharCount="2147483647" maxDepth="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="returnFaults">
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>


Any advice would be highly appreciated.


TIA


HK.Lee


 


 

Wednesday, May 27, 2015  |  From CSLA .NET Contrib

This is possbily related to my previous post around odd grid binding behaviour (waiting for approval).


I have an MVC 5 web app and a model with child objects and am binding this in a Kendo grid control.  When attempting to update a child row the model binder appears to be throwing an error, and the call to the update method in the controller never gets fired.


"System.MissingMethodException: Cannot create an instance of an interface".  The key indicator seems to be "MissingMethodException: Cannot create an instance of an interface. Object type &#39;Csla.Core.IParent"


So it looks like it's failing trying to work out the parent property of the child.  .Net can't spin up an interface - it needs the real concrete class.


Now I don't think this is a CSLA issue, but rather a Kendo grid + Csla binder interaction going on here, and I know grids and binding always throw some fun issues into the mix.  I have set the MVC default model binder to use the Csla version.


Any ideas?  The razor form binds directly to the model - not using the CslaViewModelBase (maybe I can try that).


I can work around this by using custom commands (a.k.a firing my own JavaScript ajax calls), but want to know what the real issue is here.  


I've used this technique kendo grid + poco (plain old class objects) on another project and this binding action approach all works fine.  So is it kendo + csla model binder problem?


I'll post this into the kendo forums too, but I know I'll get the Csla insights here.


Thanks,


Richard.


 


Here's part of the stack trace.


[MissingMethodException: Cannot create an instance of an interface.]


   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean&amp; canBeCached, RuntimeMethodHandleInternal&amp; ctor, Boolean&amp; bNeedSecurityCheck) +0


   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +113


   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +232


   System.Activator.CreateInstance(Type type, Boolean nonPublic) +83


   System.Activator.CreateInstance(Type type) +66


   System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +554


 


[MissingMethodException: Cannot create an instance of an interface. Object type &#39;Csla.Core.IParent&#39;.]


   System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +630


   System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1136


   System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +633


   Castle.Proxies.DefaultModelBinderProxy.BindModel_callback(ControllerContext controllerContext, ModelBindingContext bindingContext) +45


   Castle.Proxies.Invocations.DefaultModelBinder_BindModel.InvokeMethodOnTarget() +191


   Castle.DynamicProxy.AbstractInvocation.Proceed() +117

Tuesday, May 26, 2015  |  From CSLA .NET Contrib

I have this error "An asynchronous module or handler completed while an asynchronous operation was still pending" in my MVC 5 web application when deleting children from my model, via a grid which fires ajax requests to the MVC controller.


There is an async business rule on the parent, IsAsync = true and context.Complete is called when it Executes.


My delete signature in the MVC controller is (using a Kendo grid here);


public async Task<JsonResult> CustomerUser_Destroy([DataSourceRequest] DataSourceRequest request, AccountUserEdit record, int id)


and the content......


if (record != null)
               {
                   //get existing model(s)
                   var parentModel = AccountEdit.GetAccount(record.AccountId);
                   AccountUserEdit child = (from p in parentModel.CustomerAccountUsers
                                             where p.Id == id
                                             select p).First();


                    //delete it
                   parentModel.CustomerAccountUsers.Remove(child);


                    //can we save it
                   if (parentModel.IsSavable)
                   {
                       parentModel = await parentModel.SaveAsync(true);
                   }
                   else
                   {
                       //get broken rules message.
                       throw new ValidationException(MyBrokenRulesMessage.GetBrokenRules(parentModel, child));


                    }
               }
               return Json(ModelState.ToDataSourceResult());


I have this wrapped within a try catch exception block but the error is not being caught here.  


So the behavior to reproduce the error is that I can add some children in my MVC grid and they are saved ok.  If I then start removing them I get the error.  Oddly, if I refresh the browser page, and then delete a child it works.


Hard to track the error down.....so what am I doing wrong?


"An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


[InvalidOperationException: An asynchronous module or handler completed while an asynchronous operation was still pending.]


"


 


Any pointers appreciated.

Wednesday, May 20, 2015  |  From CSLA .NET Contrib


Spent a few hours yesterday making some big changes around .NET 4.6 and VS15.


In GitHub there's now a V4-5-x branch that will be used to maintain the existing 4.5 version of CSLA that uses VS13 and targets .NET 4.5, WinRT, Silverlight, etc.


The master branch in GitHub will be soon moving to VS15 to add support for .NET 4.6. This will also be version 4.6.x of CSLA.




I am explicitly dropping support for Silverlight and Windows Phone 7/8.


I have not decided yet if CSLA 4.6 will continue to support .NET 4 or 4.5. I'll make that determination as I work on .NET 4.6 support. My guess is that (at least for now) the changes will be minimal enough that I can retain support for 4 and 4.5.


If possible I plan to retain support for WinRT in CSLA 4.6, along with adding support for the Universal Windows Platform (UWP) for Windows 10 (PC, mobile, Xbox, etc.).


The start of this work is in GitHub in the rockfordlhotka/csla fork.



Tuesday, May 19, 2015  |  From CSLA .NET Contrib

I am after advice on 'life after Silverlight' (2021) and the preparation beforehand.


 


Scenario:


Sole developer (currently with 1 main commercial application (50 clients) (1 one other), using csla 4.5.3 and Silverlight, MS SQL)


 


My assumption is:


1) I will need to rewrite my application(s) to be ready around 10/12/2012 (I'm assuming there will be a 12-18 month time lag on this to take this date to say 10/21/2022)


 


Due to limited time between now and then I need to consider the above questions soon.


 


I would like to keep CSLA.net so am after advice on which development technology to use.


 


2) I am sure I will need a web-based solution (users are schools and teachers - ICT skills are poor (sorry teachers) and so I need a solution that can be deployed remotely without (minimal) user intervention)


 


3) I don't particularly like html (or should I say CSS), however at the age of 51 I would be prepared for one final push to learn/become expert at this.


 


I think some of you may suggest WPF as it is close to Silverlight - my concern is... can WPF be guaranteed to be strong post 2021.  I need a solution that is good for at least 15-20 years (my application is subscription based and will provide my pension to 65 and beyond - hopefully!! - hence why I am leaning to html5 etc.).


 


There are so many current frameworks etc. that I'm getting a little bogged down and confused.


 


I am thinking of using MVC6 (I've not done mvc before previously using win forms but not a lot and am happy to switch as I like the pattern [MVVM/MVC]) 


 


If I use MVC6 should I also learn Web API?  Is this a better fit for CSLA?


 


Which front end / binding framework?  Angular, Knockout etc and are these compatible with CSLA? - can these of other frameworks 'bind' to CSLA objects?


 


Any views on this would be warmly welcome - and I hope benefit others in this scenario.


 


One final thought might be to wait to say 2019 and hope that MS (or others) may have come up with a more streamlined (html) technology that is as good and as easy as Silverlight.

Monday, May 18, 2015  |  From CSLA .NET Contrib

I have converted the bulk of my Silverlight app to WFP without any significant issues, except for one that I would call a nightmare.  I realize it is not a Csla issue, but searching the internet I see lot of questions but no satisfactory answer.


In my SL application in the App.xaml I have quite a few Application Resources of the form:
           <vm:PlanViewModel x:Key="PlanData" />
where PlanData is then used as in DataContext=("{StaticResource PlanData}"). 


Problem comes when I try to enter that line in WPF App.xaml file.  When I enter <vm: the intelliSense promptly brings up my list of ViewModels in a drop down, where I can choose "PlanViewModel. But as soon as I finish the line by typing "/>"; an error condition tells me that there is no PlanViewModel in the very exact folder from which intelliSense had me select it!!  I have the proper reference to the ViewModel folder as an xmlns:vm line in App.xaml.


When I started with this conversion, I had the same problem with my Converters, like ItemVisibilityConverter.  That problem would suddenly appear after I brought in a few of my Page files. Once it appeared, the only solution was to drag everything to trash and start over.  Now for some reason all of that is okay.


I have struggled unsuccessfully to find an alternative to using the App.xaml for these resources but haven't been able to come up with anything satisfactory.  Would appreciate some help.


Javed


 

Friday, May 15, 2015  |  From CSLA .NET Contrib

I have a use case where i need to restrict a user when they are in a certain role to only edit "their own" record(s).


What's the best way of doing this?


I obviously know the user making the request and have/can load their roles up and if in this role, then check if the record belongs to them.  I'm thinking I can write this code in the DataPortal_Fetch method for example and throw a SecurityException.


Is that the best solution here?


The authorization rules are per type, so no help here unless we can still do some sort of per-instance rule?


Thanks.


Richard.

Thursday, May 14, 2015  |  From CSLA .NET Contrib

I'd like to see the ISerializationFormatter feature extended to allow applying my own implementation.  Being able to specify the type in the app.config/web.config similarly to how you provide a custom WcfProxy or DataPortalActivator would be perfect for me.  My current problem requires me to provide the BinaryFormatter with a custom SerializationBinder.  This feature would make this a lot easier.  Has this idea been tossed around at all?

Tuesday, May 12, 2015  |  From CSLA .NET Contrib

WinRT app with CSLA 4.5.601.0 running on devices with WWAN hitting a remote DP in the DMZ (acting as a pass through to an internal app server). We're seeing occasional errors related to connections being closed:


WebException: The underlying connection was closed: An unexpected error occurred on a receive.


SocketException: An existing connection was forcibly closed by the remote host


I see a lot of sites recommending setting HttpWebRequest.KeepAlive = false (default is true). I've not seen anything about this in the CSLA forum. Here's an MSDN post about it


Any thoughts on what the problem might be and whether this is something I should look into for our DP? Again, it is occasional, but occurs often enough that I'd like to figure out what the problem is, if possible.


Thanks,
Tim

Thursday, May 7, 2015  |  From CSLA .NET Contrib

I have an Mvc 4 webapp where in one of the controllers I somehow want to use the following function:


 


 



 



 



 



[



 



Authorize(Roles = "Administrators")]

 



 



public async Task<ActionResult> SaveProduct(ProductEdit product)

{



product =



 



await product.Save();

 



 



return RedirectToAction("Index");

}


Is there a way to make an EditableRoot.Save() to work with async/await?


Thanks,


Peter



 CSLA .NET Contrib News Feed 

 Code-gen Templates News Feed 
Monday, June 15, 2015  |  From Code-gen Templates

This forum is now an archive.


All active discussions can be found on the CSLA Forum on GitHub.


 


----


This forum is now read-only and new user registration is disallowed.


To use the new forum you will need to create a GitHub account. There is no cost to such an account.

Friday, June 12, 2015  |  From Code-gen Templates

I am fairly new to CSLA4 and in general I have had no issues working with it until I tried to create Fetch method that passed a Nullable<Boolean> value. I can pass either 'true' or 'false' however if I pass in 'null', I get a DataPortal Exception.


An unhandled exception of type 'Csla.DataPortalException' occurred in Csla.dll


Additional information: DataPortal.Fetch failed (Invalid operation - fetch not allowed)


It seems reasonable to be able to do this.


Is this a bug or simply just not supported? - Why not?

Wednesday, June 10, 2015  |  From Code-gen Templates

I am bringing my mature SL app to WPF. I am quite liberal with the use of AutoCompleteBoxes and often have more than one on a page.


The data for the dropdown of each Auto...box comes from a database table.  Instead of running to the Database for each Auto..box's list, I bring up the list for the whole page, and then use a subset of that list when the user navigates to a given Auto...box.  All my lists are of the MobileList kind.  This has worked fine in SL. (The same is happening with BusinessListBase)



In WPF the behavior is strange.  The lists do appear in the dropdown, but when I choose an item with mouse the selection immediately disappears and the box remains empty.  When I make the selection by using the up-down arrow keys on the keyboard, the selection behaves normally.



Now here is the interesting part.  If, instead of displaying the subset (Path = FilteredList), I use the entire list (Path = Model), everything works fine.  The workaround I have used on one instance of AutoCompleteBox is to create another class specifically to hold the selected subset.  Using that I can set the Path = Model, and with that things appear to work.  With the number Auto..boxses, making the change to all is, well, daunting.
So I thought I should ask if there is a simpler solution for this. 


I'll appreciate any suggestions.


Javed

Wednesday, June 10, 2015  |  From Code-gen Templates

Yes, that's true. But don't want to set the bar too high.

Opened the Csla.winrt solution. Created a new project of type "Empty Class Library (C#/XAML for HTML5) named Csla.CSHTML5. Changed the namespace to "Csla" Added conditional symbol SILVERLIGHT. Copied all the files and linked files from Csla.Silverlight project by editing the Csla.CSHTML5.csproj in a text editor.

Ended up with errors as expected. A lot of them them ambiguous reference between 'System.NonSerializedAttribute' and 'Csla.Serialization.NonSerializedAttribute' and between 'System.SerializableAttribute' and 'Csla.Serialization.SerializableAttribute'. That I don't know how to get rid of.

Browsing the project looking at the using statements I can see that these are missing:
using System.ComponentModel.DataAnnotations;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Xml.Linq;

Also I noticed that IEditableObject, INotifyDataErrorInfo, INotifyPropertyChanging, System.ComponentModel.BackgroundWorker, DoWorkEventHandler, RunWorkerCompletedEventHandler, ProgressChangedEventHandler, System.ComponentModel.AsyncCompletedEventArgs, XmlDictionaryReader, DataContractSerializer, LinkedList
 was missing.


 


Wilfred

Tuesday, June 9, 2015  |  From Code-gen Templates

I am looking at the possibility of moving this forum to GitHub.


GitHub isn't really _designed_ to be a forum, but the issues list for a project provides threaded conversations that I think can replace the functionality that we're using here on this forum, but with a much more modern user interface and experience.




https://github.com/MarimerLLC/cslaforum/issues


The above URL is the site I've set up for this - please take a look, try it out, and let me know what you think.


One way or another, this current forum needs to be replaced, as its software is no longer maintained and it will eventually just fail out from under us.


 


 

Monday, June 8, 2015  |  From Code-gen Templates

We're having a problem introducing connection manager to our existing application.  While root objects usually share the SqlConnection with their children, there are a lot of places where other BOs get involved, which end up opening their own connection.  We've introduced ConnectionManager in another application successfully and this resolved the connection pool being exhausted (it was already set to 500) and seemed to improve performance a bit too.


However we're having trouble in our main app, which has a much larger user base.  I think we've narrowed the issue to some BOs which are used by the client to get updated information frequently, approximately every minute or so.


The issue seems to be that sometimes under high load, the Asp.Net AppPool hosting the remoting (yes, remoting) site hangs.  New remoting connections are accepted, but stay forever at waiting for response, and everything just stops.  The only solution is doing an IISRESET, which hard kills the w3p.exe process hosting the remoting site (it doesn't response to a normal recycle either, although IIS still thinks things are fine). 


I've had a look at the Csla code, and I see its doing some locking which is necessary on 2-tier apps but probably less relevant for hosting under Asp.net.  I've seen the thread around that here too so I think its unlikely to be our issue.  I'm wondering if somehow async / await in combination with ConnectionManager is causing connections not to be returned to the pool (we have some errors logged indicating this).


Anyone else encountered this?

Friday, June 5, 2015  |  From Code-gen Templates

Hi all ,


currently i used csla ver 4.3.12 in c#. but recently I got a small project which need vb.net as language


so, i need a easy migration from my c# syntax into vb.net ?


 


could anyone give a suggestion ?


public static readonly PropertyInfo<string> InvNoProperty =
            RegisterProperty<string>(t => t.InvoiceNo);
        public string InvoiceNo
        {
            get { return GetProperty(InvNoProperty); }
            private set { LoadProperty(InvNoProperty, value); }
        }


into a vb.net ????


 


thanks


stefanus


 

Friday, June 5, 2015  |  From Code-gen Templates

Does anyone still use the msi installer for CSLA?


These days I just assume everything of value is in NuGet, and my primary focus with CSLA releases has been NuGet for the past couple years.


I do still maintain the msi installer, but it is kind of a PITA, especially if nobody uses it.


My train of thought is that anyone who wants the samples, source code, and other artifacts can just as easily pull the zip archive that GitHub automatically creates for each CSLA release.


What do you all think? Keep or drop the msi installer project?

Thursday, June 4, 2015  |  From Code-gen Templates

I've put an early prerelease of version 4.6 on NuGet. Details are here:



https://github.com/MarimerLLC/csla/releases/tag/v4.6.001


The primary change (and point of risk) is that I consolidated nearly all the code files into a set of shared projects, adding some compiler directives to address any outstanding conflicts between the old duplicate code files.


The upside of this is that maintenance of CSLA will now be much easier, as will adding support for new platforms or version of .NET over time.


The downside is that I may have introduced bugs if I got some of the compiler directives wrong - especially likely in the Android and iOS code (the areas most affected by the duplicate code).


If you find any issues please add issues to GitHub with details on what you encounter - thanks!


https://github.com/MarimerLLC/csla/issues



 


Friday, May 29, 2015  |  From Code-gen Templates

Hello,


Thank you in advance for any help provided here.  I read the answers on this post and still have a problem with my custom Principal/Identity implementation.


I am using Csla 4.1.0 and seem to be having a cast issue.  This is the same scenario as the OP in the linked thread where I am trying to get to custom properties that have been implemented into my CustomIdentity class.


When I try to cast Csla.ApplicationContext.User.Identity to CustomIdentity, I get "Unable to cast object of type 'System.Security.Principal.GenericPrincipal' to 'DMS.Library.Security.CustomIdentity.'


Here's the code in question:


public int UserOrgCount {


            get {


                var identity = (CustomIdentity)Csla.ApplicationContext.User.Identity;


                return identity.Orgs.Count();


            }


        }


I thought I followed the ebook pretty well and in fact everything seems to be working.  The only thing I want to get access to now is the Identity properties so that I can replace individual database calls with data that's already been loaded into my custom properties.


Let me know if there is any other information I can provide.


For reference, here is my CustomPrincipal and CustomIdentity objects:


 


using System;


using System.Security.Principal;


using Csla.Security;


using Csla.Serialization;


 


namespace DMS.Library.Security {


    [Serializable]


    public class CustomPrincipal : CslaPrincipal {


        private CustomPrincipal(IIdentity identity)


            : base(identity) { }


 


        /// <summary>


        /// 


        /// </summary>


        /// <param name="username">The user's username</param>


        /// <param name="password">The user's password</param>


        /// <param name="completed"></param>


        public static void BeginLogin(string username, string password, Action<Exception> completed) {


            DMS.Library.Security.CustomIdentity.GetCustomIdentity(username, password, (o, e) => {


                if (e.Error != null)


                    Logout();


                else


                    Csla.ApplicationContext.User = new CustomPrincipal(e.Object);


                completed(e.Error);


            });


        }


 


#if !SILVERLIGHT


 


        /// <summary>


        /// NOT IMPLEMENTED - Attempts to login the user with their username and password


        /// </summary>


        /// <param name="pUserName">The user's username</param>


        /// <param name="pPassword">The user's password</param>


        /// <remarks>


        /// As of 05/07/2015, this function is not used because it will create a circular execution of code.  


        /// Validation of credentials is handled within the ValidateUser function of each implemented Membership provider.


        /// Assuming the ValidateUser function returns true, the Principal's Load function is used instead


        /// </remarks>


        public static void Login(string username, string password) {


            throw new NotImplementedException("The CustomPrincipal Login method has not been implemented.  Refer to the remarks section of method's code for an explanation.");


            //var identity = DMS.Library.Security.CustomIdentity.GetCustomIdentity(username, password);


            //Csla.ApplicationContext.User = new CustomPrincipal(identity);


        }


 


        public static void Load(string username) {


            var identity = DMS.Library.Security.CustomIdentity.GetCustomIdentity(username);


            Csla.ApplicationContext.User = new CustomPrincipal(identity);


        }


 


#endif


 


        /// <summary>


        /// Replaces the current CustomPrincipal object with a new one that has an UnauthenticatedIdentity loaded up.


        /// </summary>


        public static void Logout() {


            Csla.ApplicationContext.User = new UnauthenticatedPrincipal();


        }


    }


}




using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Csla;

using Csla.Security;

using Csla.Serialization;

using DMS.Library.Admin;


namespace DMS.Library.Security {

    [Serializable]

    public class CustomIdentity : CslaIdentityBase<CustomIdentity> {

        

        #region Properties


            public static readonly PropertyInfo<string> EmailProperty = RegisterProperty<string>(c => c.Email);

            /// <summary>

            /// The user's E-mail

            /// </summary>

            public string Email {

                get { return GetProperty(EmailProperty); }

                private set { LoadProperty(EmailProperty, value); }

            }


            public static readonly PropertyInfo<Guid> UserIdProperty = RegisterProperty<Guid>(p => p.UserId);

            /// <summary>

            /// The user's internal identifier

            /// </summary>

            public Guid UserId {

                get { return GetProperty(UserIdProperty); }

                private set { LoadProperty(UserIdProperty, value); }

            }


            public static readonly PropertyInfo<string> FirstNameProperty = RegisterProperty<string>(c => c.FirstName);

            /// <summary>

            /// The user's first name

            /// </summary>

            public string FirstName {

                get { return GetProperty(FirstNameProperty); }

                private set { LoadProperty(FirstNameProperty, value); }

            }


            public static readonly PropertyInfo<string> LastNameProperty = RegisterProperty<string>(c => c.LastName);

            /// <summary>

            /// The user's last name

            /// </summary>

            public string LastName {

                get { return GetProperty(LastNameProperty); }

                private set { LoadProperty(LastNameProperty, value); }

            }


            public static readonly PropertyInfo<string> FullNameProperty = RegisterProperty<string>(c => c.FullName);

            /// <summary>

            /// The user's full name

            /// </summary>

            public string FullName {

                get { return GetProperty(FullNameProperty); }

                private set { LoadProperty(FullNameProperty, value); }

            }


            public static readonly PropertyInfo<string> HomeOrgStringProperty = RegisterProperty<string>(p => p.HomeOrgString);

            /// <summary>

            /// The user's Home OrgString

            /// </summary>

            public string HomeOrgString {

                get { return GetProperty(HomeOrgStringProperty); }

                private set { LoadProperty(HomeOrgStringProperty, value); }

            }


            public static readonly PropertyInfo<bool> IsApprovedProperty = RegisterProperty<bool>(p => p.IsApproved);

            /// <summary>

            /// The original membership IsApproved column

            /// </summary>

            /// <remarks>

            /// Value comes from the aspnet_Membership tables

            /// </remarks>

            public bool IsApproved {

                get { return GetProperty(IsApprovedProperty); }

                private set { LoadProperty(IsApprovedProperty, value); }

            }


            public static readonly PropertyInfo<List<string>> OrgsProperty = RegisterProperty<List<string>>(p => p.Orgs);

            /// <summary>

            /// Returns the list of Departments that the user belongs to

            /// </summary>

            public List<string> Orgs {

                get { return GetProperty(OrgsProperty); }

                private set { LoadProperty(OrgsProperty, value); }

            }


            public static readonly PropertyInfo<string> AppNameProperty = RegisterProperty<string>(p => p.AppName);

            public string AppName {

                get { return "AppName"; }

            }


    #endregion


        public static void GetCustomIdentity(string username, string password, EventHandler<DataPortalResult<CustomIdentity>> callback) {

            DataPortal.BeginFetch<CustomIdentity>(new UsernameCriteria(username, password), callback);

        }


#if !SILVERLIGHT


        /// <summary>

        /// Gets the user after authenticating them with their username and password

        /// </summary>

        /// <param name="pUserName">The user's employee number</param>

        /// <param name="pPassword">The user's password</param>

        /// <returns></returns>

        public static CustomIdentity GetCustomIdentity(string username, string password) {

            return DataPortal.Fetch<CustomIdentity>(new UsernameCriteria(username, password));

        }

        

        private void DataPortal_Fetch(UsernameCriteria criteria) {

            AuthenticationType = "Custom";

            using (var mgr = DataAccess.DalFactory.GetManager()) {

                var dal = mgr.GetProvider<DataAccess.IIdentityDal>();

                if (dal.VerifyUser(criteria.Username, criteria.Password))

                    LoadUserData(criteria.Username, dal);

            }

        }


        /// <summary>

        /// Gets the user based on their username

        /// </summary>

        /// <param name="pUserName">The user's employee number</param>

        /// <returns></returns>

        internal static CustomIdentity GetCustomIdentity(string username) {

            return DataPortal.Fetch<CustomIdentity>(username);

        }


        private void DataPortal_Fetch(string username) {

            AuthenticationType = "Custom";

            using (var mgr = DataAccess.DalFactory.GetManager()) {

                var dal = mgr.GetProvider<DataAccess.IIdentityDal>();

                LoadUserData(username, dal);

            }

        }


        /// <summary>

        /// Uses the DataAccess DalFactory to dynamically load the required membership provider

        /// </summary>

        /// <param name="pUserName">The user's employee number</param>

        /// <param name="dal">The Identity's data access object</param>

        private void LoadUserData(string pUserName, DataAccess.IIdentityDal dal) {

            var userData = dal.GetUser(pUserName);

            //Step 1 authentication loading - If the user exists in the membership tables, the user is temporarily authenticated

            this.IsAuthenticated = (userData != null);

            

            if (this.IsAuthenticated) {


                this.Name = userData.UserName;

                this.FirstName = userData.FirstName;

                this.LastName = userData.LastName;

                this.FullName = string.Format("{0} {1}", userData.FirstName, userData.LastName);

                this.Email = userData.Email;

                this.UserId = userData.UserId;

                this.HomeOrgString = userData.HomeOrgString;

                this.IsApproved = userData.IsApproved;


                //Step 2 authentication loading - Update the Identity's IsAuthenticated property based on the membership table

                this.IsAuthenticated = this.IsApproved;


                //Initialize the MobileList property and then load up the roles once we've gotten them

                this.Roles = new Csla.Core.MobileList<string>();

                string[] _roles = UserRole.GetRolesForUser(pUserName, string.Empty, true);

                foreach (var role in _roles) {

                    this.Roles.Add(role);

                }


                //Load up the Orgs the user belongs to

                this.Orgs = UserOrg.GetOrgsForUser(pUserName, true, false).ToList();


                //Step 3 authentication loading - Check to make sure that even if the user is authenticated with AD and exists in the membership table, the user has at least 1 Org and Role

                if (!(this.Orgs.Count() > 0 && this.Roles.Count() > 0)) {

                    this.IsAuthenticated = false;

                    throw new InvalidOperationException(string.Format("User {0} does not have access to any departments and/or roles.\n    Org Count: {1};\n    Role Count: {2}", this.Name, this.Orgs.Count(), this.Roles.Count()));

                }

            }

        }


#endif


    }

}

Thursday, May 28, 2015  |  From Code-gen Templates

Hi All,


In my WPF project with CSLA v 4.70, I configured mobileProxy same with Project tracker .


However, when I try to fetch some simple readonly list, Dataportal_fetch has never been touched.


On debugging, error was fired at following line of fetch method of mobileproxy.cs.


#if !NET40
          response = await proxy.FetchAsync(request).ConfigureAwait(false);
#else


and  stack trace shows


Csla.DataPortalClient.MobileProxy.<Fetch>d__8.MoveNext() file d:\DotNetApps\CNS\Source\Business\Csla\Csla\DataPortalClient\MobileProxy.cs:line 327


and inner error message says ' returned internal server error 500..'


I tried both calling method of  async and callback fetch, but had same error.


   CNS.Business.Entity.LineProcessInfoList.GetLineProcessInfoList(new Business.Entity.LineProcessCriteria(true, 1), (o, args) =>
            {
                if (args.Error == null)
                    lines = args.Object;
            });


 var list = await CNS.Business.Entity.LineProcessInfoList.GetLineProcessInfoListAsync(new Business.Entity.LineProcessCriteria(true, 1));


Pls give me any advise what I missed or share your experience. Following is each config.


app.config


  <appSettings>
    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.MobileProxy, Csla"/>
    <add key="CslaDataPortalUrl" value="http://localhost:3969/slPortal.svc"/>
  </appSettings>


web.config


 <appSettings>
    <add key="CslaAuthentication" value="Csla" />
  </appSettings>
  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service name="Csla.Server.Hosts.WcfPortal" behaviorConfiguration="returnFaults">
        <endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IWcfPortal"
                  contract="Csla.Server.Hosts.IWcfPortal" />
      </service>
      <service name="Csla.Server.Hosts.Mobile.WcfPortal" behaviorConfiguration="returnFaults">
        <endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IWcfPortal"
                  contract="Csla.Server.Hosts.Mobile.IWcfPortal" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"
                 maxBufferSize="2147483647">
          <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
                        maxNameTableCharCount="2147483647" maxDepth="2147483647" />
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="wsHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647">
          <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
                        maxNameTableCharCount="2147483647" maxDepth="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="returnFaults">
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>


Any advice would be highly appreciated.


TIA


HK.Lee


 


 

Wednesday, May 27, 2015  |  From Code-gen Templates

This is possbily related to my previous post around odd grid binding behaviour (waiting for approval).


I have an MVC 5 web app and a model with child objects and am binding this in a Kendo grid control.  When attempting to update a child row the model binder appears to be throwing an error, and the call to the update method in the controller never gets fired.


"System.MissingMethodException: Cannot create an instance of an interface".  The key indicator seems to be "MissingMethodException: Cannot create an instance of an interface. Object type &#39;Csla.Core.IParent"


So it looks like it's failing trying to work out the parent property of the child.  .Net can't spin up an interface - it needs the real concrete class.


Now I don't think this is a CSLA issue, but rather a Kendo grid + Csla binder interaction going on here, and I know grids and binding always throw some fun issues into the mix.  I have set the MVC default model binder to use the Csla version.


Any ideas?  The razor form binds directly to the model - not using the CslaViewModelBase (maybe I can try that).


I can work around this by using custom commands (a.k.a firing my own JavaScript ajax calls), but want to know what the real issue is here.  


I've used this technique kendo grid + poco (plain old class objects) on another project and this binding action approach all works fine.  So is it kendo + csla model binder problem?


I'll post this into the kendo forums too, but I know I'll get the Csla insights here.


Thanks,


Richard.


 


Here's part of the stack trace.


[MissingMethodException: Cannot create an instance of an interface.]


   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean&amp; canBeCached, RuntimeMethodHandleInternal&amp; ctor, Boolean&amp; bNeedSecurityCheck) +0


   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +113


   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +232


   System.Activator.CreateInstance(Type type, Boolean nonPublic) +83


   System.Activator.CreateInstance(Type type) +66


   System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +554


 


[MissingMethodException: Cannot create an instance of an interface. Object type &#39;Csla.Core.IParent&#39;.]


   System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +630


   System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1136


   System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +633


   Castle.Proxies.DefaultModelBinderProxy.BindModel_callback(ControllerContext controllerContext, ModelBindingContext bindingContext) +45


   Castle.Proxies.Invocations.DefaultModelBinder_BindModel.InvokeMethodOnTarget() +191


   Castle.DynamicProxy.AbstractInvocation.Proceed() +117

Tuesday, May 26, 2015  |  From Code-gen Templates

I have this error "An asynchronous module or handler completed while an asynchronous operation was still pending" in my MVC 5 web application when deleting children from my model, via a grid which fires ajax requests to the MVC controller.


There is an async business rule on the parent, IsAsync = true and context.Complete is called when it Executes.


My delete signature in the MVC controller is (using a Kendo grid here);


public async Task<JsonResult> CustomerUser_Destroy([DataSourceRequest] DataSourceRequest request, AccountUserEdit record, int id)


and the content......


if (record != null)
               {
                   //get existing model(s)
                   var parentModel = AccountEdit.GetAccount(record.AccountId);
                   AccountUserEdit child = (from p in parentModel.CustomerAccountUsers
                                             where p.Id == id
                                             select p).First();


                    //delete it
                   parentModel.CustomerAccountUsers.Remove(child);


                    //can we save it
                   if (parentModel.IsSavable)
                   {
                       parentModel = await parentModel.SaveAsync(true);
                   }
                   else
                   {
                       //get broken rules message.
                       throw new ValidationException(MyBrokenRulesMessage.GetBrokenRules(parentModel, child));


                    }
               }
               return Json(ModelState.ToDataSourceResult());


I have this wrapped within a try catch exception block but the error is not being caught here.  


So the behavior to reproduce the error is that I can add some children in my MVC grid and they are saved ok.  If I then start removing them I get the error.  Oddly, if I refresh the browser page, and then delete a child it works.


Hard to track the error down.....so what am I doing wrong?


"An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


[InvalidOperationException: An asynchronous module or handler completed while an asynchronous operation was still pending.]


"


 


Any pointers appreciated.

Wednesday, May 20, 2015  |  From Code-gen Templates


Spent a few hours yesterday making some big changes around .NET 4.6 and VS15.


In GitHub there's now a V4-5-x branch that will be used to maintain the existing 4.5 version of CSLA that uses VS13 and targets .NET 4.5, WinRT, Silverlight, etc.


The master branch in GitHub will be soon moving to VS15 to add support for .NET 4.6. This will also be version 4.6.x of CSLA.




I am explicitly dropping support for Silverlight and Windows Phone 7/8.


I have not decided yet if CSLA 4.6 will continue to support .NET 4 or 4.5. I'll make that determination as I work on .NET 4.6 support. My guess is that (at least for now) the changes will be minimal enough that I can retain support for 4 and 4.5.


If possible I plan to retain support for WinRT in CSLA 4.6, along with adding support for the Universal Windows Platform (UWP) for Windows 10 (PC, mobile, Xbox, etc.).


The start of this work is in GitHub in the rockfordlhotka/csla fork.



Tuesday, May 19, 2015  |  From Code-gen Templates

I am after advice on 'life after Silverlight' (2021) and the preparation beforehand.


 


Scenario:


Sole developer (currently with 1 main commercial application (50 clients) (1 one other), using csla 4.5.3 and Silverlight, MS SQL)


 


My assumption is:


1) I will need to rewrite my application(s) to be ready around 10/12/2012 (I'm assuming there will be a 12-18 month time lag on this to take this date to say 10/21/2022)


 


Due to limited time between now and then I need to consider the above questions soon.


 


I would like to keep CSLA.net so am after advice on which development technology to use.


 


2) I am sure I will need a web-based solution (users are schools and teachers - ICT skills are poor (sorry teachers) and so I need a solution that can be deployed remotely without (minimal) user intervention)


 


3) I don't particularly like html (or should I say CSS), however at the age of 51 I would be prepared for one final push to learn/become expert at this.


 


I think some of you may suggest WPF as it is close to Silverlight - my concern is... can WPF be guaranteed to be strong post 2021.  I need a solution that is good for at least 15-20 years (my application is subscription based and will provide my pension to 65 and beyond - hopefully!! - hence why I am leaning to html5 etc.).


 


There are so many current frameworks etc. that I'm getting a little bogged down and confused.


 


I am thinking of using MVC6 (I've not done mvc before previously using win forms but not a lot and am happy to switch as I like the pattern [MVVM/MVC]) 


 


If I use MVC6 should I also learn Web API?  Is this a better fit for CSLA?


 


Which front end / binding framework?  Angular, Knockout etc and are these compatible with CSLA? - can these of other frameworks 'bind' to CSLA objects?


 


Any views on this would be warmly welcome - and I hope benefit others in this scenario.


 


One final thought might be to wait to say 2019 and hope that MS (or others) may have come up with a more streamlined (html) technology that is as good and as easy as Silverlight.

Monday, May 18, 2015  |  From Code-gen Templates

I have converted the bulk of my Silverlight app to WFP without any significant issues, except for one that I would call a nightmare.  I realize it is not a Csla issue, but searching the internet I see lot of questions but no satisfactory answer.


In my SL application in the App.xaml I have quite a few Application Resources of the form:
           <vm:PlanViewModel x:Key="PlanData" />
where PlanData is then used as in DataContext=("{StaticResource PlanData}"). 


Problem comes when I try to enter that line in WPF App.xaml file.  When I enter <vm: the intelliSense promptly brings up my list of ViewModels in a drop down, where I can choose "PlanViewModel. But as soon as I finish the line by typing "/>"; an error condition tells me that there is no PlanViewModel in the very exact folder from which intelliSense had me select it!!  I have the proper reference to the ViewModel folder as an xmlns:vm line in App.xaml.


When I started with this conversion, I had the same problem with my Converters, like ItemVisibilityConverter.  That problem would suddenly appear after I brought in a few of my Page files. Once it appeared, the only solution was to drag everything to trash and start over.  Now for some reason all of that is okay.


I have struggled unsuccessfully to find an alternative to using the App.xaml for these resources but haven't been able to come up with anything satisfactory.  Would appreciate some help.


Javed


 

Friday, May 15, 2015  |  From Code-gen Templates

I have a use case where i need to restrict a user when they are in a certain role to only edit "their own" record(s).


What's the best way of doing this?


I obviously know the user making the request and have/can load their roles up and if in this role, then check if the record belongs to them.  I'm thinking I can write this code in the DataPortal_Fetch method for example and throw a SecurityException.


Is that the best solution here?


The authorization rules are per type, so no help here unless we can still do some sort of per-instance rule?


Thanks.


Richard.

Thursday, May 14, 2015  |  From Code-gen Templates

I'd like to see the ISerializationFormatter feature extended to allow applying my own implementation.  Being able to specify the type in the app.config/web.config similarly to how you provide a custom WcfProxy or DataPortalActivator would be perfect for me.  My current problem requires me to provide the BinaryFormatter with a custom SerializationBinder.  This feature would make this a lot easier.  Has this idea been tossed around at all?

Tuesday, May 12, 2015  |  From Code-gen Templates

WinRT app with CSLA 4.5.601.0 running on devices with WWAN hitting a remote DP in the DMZ (acting as a pass through to an internal app server). We're seeing occasional errors related to connections being closed:


WebException: The underlying connection was closed: An unexpected error occurred on a receive.


SocketException: An existing connection was forcibly closed by the remote host


I see a lot of sites recommending setting HttpWebRequest.KeepAlive = false (default is true). I've not seen anything about this in the CSLA forum. Here's an MSDN post about it


Any thoughts on what the problem might be and whether this is something I should look into for our DP? Again, it is occasional, but occurs often enough that I'd like to figure out what the problem is, if possible.


Thanks,
Tim

Thursday, May 7, 2015  |  From Code-gen Templates

I have an Mvc 4 webapp where in one of the controllers I somehow want to use the following function:


 


 



 



 



 



[



 



Authorize(Roles = "Administrators")]

 



 



public async Task<ActionResult> SaveProduct(ProductEdit product)

{



product =



 



await product.Save();

 



 



return RedirectToAction("Index");

}


Is there a way to make an EditableRoot.Save() to work with async/await?


Thanks,


Peter



 Code-gen Templates News Feed 

 VS Templates News Feed 
Monday, June 15, 2015  |  From VS Templates

This forum is now an archive.


All active discussions can be found on the CSLA Forum on GitHub.


 


----


This forum is now read-only and new user registration is disallowed.


To use the new forum you will need to create a GitHub account. There is no cost to such an account.

Friday, June 12, 2015  |  From VS Templates

I am fairly new to CSLA4 and in general I have had no issues working with it until I tried to create Fetch method that passed a Nullable<Boolean> value. I can pass either 'true' or 'false' however if I pass in 'null', I get a DataPortal Exception.


An unhandled exception of type 'Csla.DataPortalException' occurred in Csla.dll


Additional information: DataPortal.Fetch failed (Invalid operation - fetch not allowed)


It seems reasonable to be able to do this.


Is this a bug or simply just not supported? - Why not?

Wednesday, June 10, 2015  |  From VS Templates

I am bringing my mature SL app to WPF. I am quite liberal with the use of AutoCompleteBoxes and often have more than one on a page.


The data for the dropdown of each Auto...box comes from a database table.  Instead of running to the Database for each Auto..box's list, I bring up the list for the whole page, and then use a subset of that list when the user navigates to a given Auto...box.  All my lists are of the MobileList kind.  This has worked fine in SL. (The same is happening with BusinessListBase)



In WPF the behavior is strange.  The lists do appear in the dropdown, but when I choose an item with mouse the selection immediately disappears and the box remains empty.  When I make the selection by using the up-down arrow keys on the keyboard, the selection behaves normally.



Now here is the interesting part.  If, instead of displaying the subset (Path = FilteredList), I use the entire list (Path = Model), everything works fine.  The workaround I have used on one instance of AutoCompleteBox is to create another class specifically to hold the selected subset.  Using that I can set the Path = Model, and with that things appear to work.  With the number Auto..boxses, making the change to all is, well, daunting.
So I thought I should ask if there is a simpler solution for this. 


I'll appreciate any suggestions.


Javed

Wednesday, June 10, 2015  |  From VS Templates

Yes, that's true. But don't want to set the bar too high.

Opened the Csla.winrt solution. Created a new project of type "Empty Class Library (C#/XAML for HTML5) named Csla.CSHTML5. Changed the namespace to "Csla" Added conditional symbol SILVERLIGHT. Copied all the files and linked files from Csla.Silverlight project by editing the Csla.CSHTML5.csproj in a text editor.

Ended up with errors as expected. A lot of them them ambiguous reference between 'System.NonSerializedAttribute' and 'Csla.Serialization.NonSerializedAttribute' and between 'System.SerializableAttribute' and 'Csla.Serialization.SerializableAttribute'. That I don't know how to get rid of.

Browsing the project looking at the using statements I can see that these are missing:
using System.ComponentModel.DataAnnotations;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Xml.Linq;

Also I noticed that IEditableObject, INotifyDataErrorInfo, INotifyPropertyChanging, System.ComponentModel.BackgroundWorker, DoWorkEventHandler, RunWorkerCompletedEventHandler, ProgressChangedEventHandler, System.ComponentModel.AsyncCompletedEventArgs, XmlDictionaryReader, DataContractSerializer, LinkedList
 was missing.


 


Wilfred

Tuesday, June 9, 2015  |  From VS Templates

I am looking at the possibility of moving this forum to GitHub.


GitHub isn't really _designed_ to be a forum, but the issues list for a project provides threaded conversations that I think can replace the functionality that we're using here on this forum, but with a much more modern user interface and experience.




https://github.com/MarimerLLC/cslaforum/issues


The above URL is the site I've set up for this - please take a look, try it out, and let me know what you think.


One way or another, this current forum needs to be replaced, as its software is no longer maintained and it will eventually just fail out from under us.


 


 

Monday, June 8, 2015  |  From VS Templates

We're having a problem introducing connection manager to our existing application.  While root objects usually share the SqlConnection with their children, there are a lot of places where other BOs get involved, which end up opening their own connection.  We've introduced ConnectionManager in another application successfully and this resolved the connection pool being exhausted (it was already set to 500) and seemed to improve performance a bit too.


However we're having trouble in our main app, which has a much larger user base.  I think we've narrowed the issue to some BOs which are used by the client to get updated information frequently, approximately every minute or so.


The issue seems to be that sometimes under high load, the Asp.Net AppPool hosting the remoting (yes, remoting) site hangs.  New remoting connections are accepted, but stay forever at waiting for response, and everything just stops.  The only solution is doing an IISRESET, which hard kills the w3p.exe process hosting the remoting site (it doesn't response to a normal recycle either, although IIS still thinks things are fine). 


I've had a look at the Csla code, and I see its doing some locking which is necessary on 2-tier apps but probably less relevant for hosting under Asp.net.  I've seen the thread around that here too so I think its unlikely to be our issue.  I'm wondering if somehow async / await in combination with ConnectionManager is causing connections not to be returned to the pool (we have some errors logged indicating this).


Anyone else encountered this?

Friday, June 5, 2015  |  From VS Templates

Hi all ,


currently i used csla ver 4.3.12 in c#. but recently I got a small project which need vb.net as language


so, i need a easy migration from my c# syntax into vb.net ?


 


could anyone give a suggestion ?


public static readonly PropertyInfo<string> InvNoProperty =
            RegisterProperty<string>(t => t.InvoiceNo);
        public string InvoiceNo
        {
            get { return GetProperty(InvNoProperty); }
            private set { LoadProperty(InvNoProperty, value); }
        }


into a vb.net ????


 


thanks


stefanus


 

Friday, June 5, 2015  |  From VS Templates

Does anyone still use the msi installer for CSLA?


These days I just assume everything of value is in NuGet, and my primary focus with CSLA releases has been NuGet for the past couple years.


I do still maintain the msi installer, but it is kind of a PITA, especially if nobody uses it.


My train of thought is that anyone who wants the samples, source code, and other artifacts can just as easily pull the zip archive that GitHub automatically creates for each CSLA release.


What do you all think? Keep or drop the msi installer project?

Thursday, June 4, 2015  |  From VS Templates

I've put an early prerelease of version 4.6 on NuGet. Details are here:



https://github.com/MarimerLLC/csla/releases/tag/v4.6.001


The primary change (and point of risk) is that I consolidated nearly all the code files into a set of shared projects, adding some compiler directives to address any outstanding conflicts between the old duplicate code files.


The upside of this is that maintenance of CSLA will now be much easier, as will adding support for new platforms or version of .NET over time.


The downside is that I may have introduced bugs if I got some of the compiler directives wrong - especially likely in the Android and iOS code (the areas most affected by the duplicate code).


If you find any issues please add issues to GitHub with details on what you encounter - thanks!


https://github.com/MarimerLLC/csla/issues



 


Monday, June 1, 2015  |  From VS Templates

Beta 4 of C#/XAML for HTML5 is out. http://cshtml5.com/


Now with Full support of C# 5.0.


According to the roadmap if everything goes as planned: Most of the features required to easily port Silverlight apps and other C#/XAML-based apps to HTML5 are available in Mid 2016.


If there is a feature we need to make this work with CSLA we can vote for it. What should I vote for?

Friday, May 29, 2015  |  From VS Templates

Hello,


Thank you in advance for any help provided here.  I read the answers on this post and still have a problem with my custom Principal/Identity implementation.


I am using Csla 4.1.0 and seem to be having a cast issue.  This is the same scenario as the OP in the linked thread where I am trying to get to custom properties that have been implemented into my CustomIdentity class.


When I try to cast Csla.ApplicationContext.User.Identity to CustomIdentity, I get "Unable to cast object of type 'System.Security.Principal.GenericPrincipal' to 'DMS.Library.Security.CustomIdentity.'


Here's the code in question:


public int UserOrgCount {


            get {


                var identity = (CustomIdentity)Csla.ApplicationContext.User.Identity;


                return identity.Orgs.Count();


            }


        }


I thought I followed the ebook pretty well and in fact everything seems to be working.  The only thing I want to get access to now is the Identity properties so that I can replace individual database calls with data that's already been loaded into my custom properties.


Let me know if there is any other information I can provide.


For reference, here is my CustomPrincipal and CustomIdentity objects:


 


using System;


using System.Security.Principal;


using Csla.Security;


using Csla.Serialization;


 


namespace DMS.Library.Security {


    [Serializable]


    public class CustomPrincipal : CslaPrincipal {


        private CustomPrincipal(IIdentity identity)


            : base(identity) { }


 


        /// <summary>


        /// 


        /// </summary>


        /// <param name="username">The user's username</param>


        /// <param name="password">The user's password</param>


        /// <param name="completed"></param>


        public static void BeginLogin(string username, string password, Action<Exception> completed) {


            DMS.Library.Security.CustomIdentity.GetCustomIdentity(username, password, (o, e) => {


                if (e.Error != null)


                    Logout();


                else


                    Csla.ApplicationContext.User = new CustomPrincipal(e.Object);


                completed(e.Error);


            });


        }


 


#if !SILVERLIGHT


 


        /// <summary>


        /// NOT IMPLEMENTED - Attempts to login the user with their username and password


        /// </summary>


        /// <param name="pUserName">The user's username</param>


        /// <param name="pPassword">The user's password</param>


        /// <remarks>


        /// As of 05/07/2015, this function is not used because it will create a circular execution of code.  


        /// Validation of credentials is handled within the ValidateUser function of each implemented Membership provider.


        /// Assuming the ValidateUser function returns true, the Principal's Load function is used instead


        /// </remarks>


        public static void Login(string username, string password) {


            throw new NotImplementedException("The CustomPrincipal Login method has not been implemented.  Refer to the remarks section of method's code for an explanation.");


            //var identity = DMS.Library.Security.CustomIdentity.GetCustomIdentity(username, password);


            //Csla.ApplicationContext.User = new CustomPrincipal(identity);


        }


 


        public static void Load(string username) {


            var identity = DMS.Library.Security.CustomIdentity.GetCustomIdentity(username);


            Csla.ApplicationContext.User = new CustomPrincipal(identity);


        }


 


#endif


 


        /// <summary>


        /// Replaces the current CustomPrincipal object with a new one that has an UnauthenticatedIdentity loaded up.


        /// </summary>


        public static void Logout() {


            Csla.ApplicationContext.User = new UnauthenticatedPrincipal();


        }


    }


}




using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Csla;

using Csla.Security;

using Csla.Serialization;

using DMS.Library.Admin;


namespace DMS.Library.Security {

    [Serializable]

    public class CustomIdentity : CslaIdentityBase<CustomIdentity> {

        

        #region Properties


            public static readonly PropertyInfo<string> EmailProperty = RegisterProperty<string>(c => c.Email);

            /// <summary>

            /// The user's E-mail

            /// </summary>

            public string Email {

                get { return GetProperty(EmailProperty); }

                private set { LoadProperty(EmailProperty, value); }

            }


            public static readonly PropertyInfo<Guid> UserIdProperty = RegisterProperty<Guid>(p => p.UserId);

            /// <summary>

            /// The user's internal identifier

            /// </summary>

            public Guid UserId {

                get { return GetProperty(UserIdProperty); }

                private set { LoadProperty(UserIdProperty, value); }

            }


            public static readonly PropertyInfo<string> FirstNameProperty = RegisterProperty<string>(c => c.FirstName);

            /// <summary>

            /// The user's first name

            /// </summary>

            public string FirstName {

                get { return GetProperty(FirstNameProperty); }

                private set { LoadProperty(FirstNameProperty, value); }

            }


            public static readonly PropertyInfo<string> LastNameProperty = RegisterProperty<string>(c => c.LastName);

            /// <summary>

            /// The user's last name

            /// </summary>

            public string LastName {

                get { return GetProperty(LastNameProperty); }

                private set { LoadProperty(LastNameProperty, value); }

            }


            public static readonly PropertyInfo<string> FullNameProperty = RegisterProperty<string>(c => c.FullName);

            /// <summary>

            /// The user's full name

            /// </summary>

            public string FullName {

                get { return GetProperty(FullNameProperty); }

                private set { LoadProperty(FullNameProperty, value); }

            }


            public static readonly PropertyInfo<string> HomeOrgStringProperty = RegisterProperty<string>(p => p.HomeOrgString);

            /// <summary>

            /// The user's Home OrgString

            /// </summary>

            public string HomeOrgString {

                get { return GetProperty(HomeOrgStringProperty); }

                private set { LoadProperty(HomeOrgStringProperty, value); }

            }


            public static readonly PropertyInfo<bool> IsApprovedProperty = RegisterProperty<bool>(p => p.IsApproved);

            /// <summary>

            /// The original membership IsApproved column

            /// </summary>

            /// <remarks>

            /// Value comes from the aspnet_Membership tables

            /// </remarks>

            public bool IsApproved {

                get { return GetProperty(IsApprovedProperty); }

                private set { LoadProperty(IsApprovedProperty, value); }

            }


            public static readonly PropertyInfo<List<string>> OrgsProperty = RegisterProperty<List<string>>(p => p.Orgs);

            /// <summary>

            /// Returns the list of Departments that the user belongs to

            /// </summary>

            public List<string> Orgs {

                get { return GetProperty(OrgsProperty); }

                private set { LoadProperty(OrgsProperty, value); }

            }


            public static readonly PropertyInfo<string> AppNameProperty = RegisterProperty<string>(p => p.AppName);

            public string AppName {

                get { return "AppName"; }

            }


    #endregion


        public static void GetCustomIdentity(string username, string password, EventHandler<DataPortalResult<CustomIdentity>> callback) {

            DataPortal.BeginFetch<CustomIdentity>(new UsernameCriteria(username, password), callback);

        }


#if !SILVERLIGHT


        /// <summary>

        /// Gets the user after authenticating them with their username and password

        /// </summary>

        /// <param name="pUserName">The user's employee number</param>

        /// <param name="pPassword">The user's password</param>

        /// <returns></returns>

        public static CustomIdentity GetCustomIdentity(string username, string password) {

            return DataPortal.Fetch<CustomIdentity>(new UsernameCriteria(username, password));

        }

        

        private void DataPortal_Fetch(UsernameCriteria criteria) {

            AuthenticationType = "Custom";

            using (var mgr = DataAccess.DalFactory.GetManager()) {

                var dal = mgr.GetProvider<DataAccess.IIdentityDal>();

                if (dal.VerifyUser(criteria.Username, criteria.Password))

                    LoadUserData(criteria.Username, dal);

            }

        }


        /// <summary>

        /// Gets the user based on their username

        /// </summary>

        /// <param name="pUserName">The user's employee number</param>

        /// <returns></returns>

        internal static CustomIdentity GetCustomIdentity(string username) {

            return DataPortal.Fetch<CustomIdentity>(username);

        }


        private void DataPortal_Fetch(string username) {

            AuthenticationType = "Custom";

            using (var mgr = DataAccess.DalFactory.GetManager()) {

                var dal = mgr.GetProvider<DataAccess.IIdentityDal>();

                LoadUserData(username, dal);

            }

        }


        /// <summary>

        /// Uses the DataAccess DalFactory to dynamically load the required membership provider

        /// </summary>

        /// <param name="pUserName">The user's employee number</param>

        /// <param name="dal">The Identity's data access object</param>

        private void LoadUserData(string pUserName, DataAccess.IIdentityDal dal) {

            var userData = dal.GetUser(pUserName);

            //Step 1 authentication loading - If the user exists in the membership tables, the user is temporarily authenticated

            this.IsAuthenticated = (userData != null);

            

            if (this.IsAuthenticated) {


                this.Name = userData.UserName;

                this.FirstName = userData.FirstName;

                this.LastName = userData.LastName;

                this.FullName = string.Format("{0} {1}", userData.FirstName, userData.LastName);

                this.Email = userData.Email;

                this.UserId = userData.UserId;

                this.HomeOrgString = userData.HomeOrgString;

                this.IsApproved = userData.IsApproved;


                //Step 2 authentication loading - Update the Identity's IsAuthenticated property based on the membership table

                this.IsAuthenticated = this.IsApproved;


                //Initialize the MobileList property and then load up the roles once we've gotten them

                this.Roles = new Csla.Core.MobileList<string>();

                string[] _roles = UserRole.GetRolesForUser(pUserName, string.Empty, true);

                foreach (var role in _roles) {

                    this.Roles.Add(role);

                }


                //Load up the Orgs the user belongs to

                this.Orgs = UserOrg.GetOrgsForUser(pUserName, true, false).ToList();


                //Step 3 authentication loading - Check to make sure that even if the user is authenticated with AD and exists in the membership table, the user has at least 1 Org and Role

                if (!(this.Orgs.Count() > 0 && this.Roles.Count() > 0)) {

                    this.IsAuthenticated = false;

                    throw new InvalidOperationException(string.Format("User {0} does not have access to any departments and/or roles.\n    Org Count: {1};\n    Role Count: {2}", this.Name, this.Orgs.Count(), this.Roles.Count()));

                }

            }

        }


#endif


    }

}

Thursday, May 28, 2015  |  From VS Templates

Hi All,


In my WPF project with CSLA v 4.70, I configured mobileProxy same with Project tracker .


However, when I try to fetch some simple readonly list, Dataportal_fetch has never been touched.


On debugging, error was fired at following line of fetch method of mobileproxy.cs.


#if !NET40
          response = await proxy.FetchAsync(request).ConfigureAwait(false);
#else


and  stack trace shows


Csla.DataPortalClient.MobileProxy.<Fetch>d__8.MoveNext() file d:\DotNetApps\CNS\Source\Business\Csla\Csla\DataPortalClient\MobileProxy.cs:line 327


and inner error message says ' returned internal server error 500..'


I tried both calling method of  async and callback fetch, but had same error.


   CNS.Business.Entity.LineProcessInfoList.GetLineProcessInfoList(new Business.Entity.LineProcessCriteria(true, 1), (o, args) =>
            {
                if (args.Error == null)
                    lines = args.Object;
            });


 var list = await CNS.Business.Entity.LineProcessInfoList.GetLineProcessInfoListAsync(new Business.Entity.LineProcessCriteria(true, 1));


Pls give me any advise what I missed or share your experience. Following is each config.


app.config


  <appSettings>
    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.MobileProxy, Csla"/>
    <add key="CslaDataPortalUrl" value="http://localhost:3969/slPortal.svc"/>
  </appSettings>


web.config


 <appSettings>
    <add key="CslaAuthentication" value="Csla" />
  </appSettings>
  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service name="Csla.Server.Hosts.WcfPortal" behaviorConfiguration="returnFaults">
        <endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IWcfPortal"
                  contract="Csla.Server.Hosts.IWcfPortal" />
      </service>
      <service name="Csla.Server.Hosts.Mobile.WcfPortal" behaviorConfiguration="returnFaults">
        <endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IWcfPortal"
                  contract="Csla.Server.Hosts.Mobile.IWcfPortal" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"
                 maxBufferSize="2147483647">
          <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
                        maxNameTableCharCount="2147483647" maxDepth="2147483647" />
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="wsHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647">
          <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
                        maxNameTableCharCount="2147483647" maxDepth="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="returnFaults">
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>


Any advice would be highly appreciated.


TIA


HK.Lee


 


 

Wednesday, May 27, 2015  |  From VS Templates

This is possbily related to my previous post around odd grid binding behaviour (waiting for approval).


I have an MVC 5 web app and a model with child objects and am binding this in a Kendo grid control.  When attempting to update a child row the model binder appears to be throwing an error, and the call to the update method in the controller never gets fired.


"System.MissingMethodException: Cannot create an instance of an interface".  The key indicator seems to be "MissingMethodException: Cannot create an instance of an interface. Object type &#39;Csla.Core.IParent"


So it looks like it's failing trying to work out the parent property of the child.  .Net can't spin up an interface - it needs the real concrete class.


Now I don't think this is a CSLA issue, but rather a Kendo grid + Csla binder interaction going on here, and I know grids and binding always throw some fun issues into the mix.  I have set the MVC default model binder to use the Csla version.


Any ideas?  The razor form binds directly to the model - not using the CslaViewModelBase (maybe I can try that).


I can work around this by using custom commands (a.k.a firing my own JavaScript ajax calls), but want to know what the real issue is here.  


I've used this technique kendo grid + poco (plain old class objects) on another project and this binding action approach all works fine.  So is it kendo + csla model binder problem?


I'll post this into the kendo forums too, but I know I'll get the Csla insights here.


Thanks,


Richard.


 


Here's part of the stack trace.


[MissingMethodException: Cannot create an instance of an interface.]


   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean&amp; canBeCached, RuntimeMethodHandleInternal&amp; ctor, Boolean&amp; bNeedSecurityCheck) +0


   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +113


   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +232


   System.Activator.CreateInstance(Type type, Boolean nonPublic) +83


   System.Activator.CreateInstance(Type type) +66


   System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +554


 


[MissingMethodException: Cannot create an instance of an interface. Object type &#39;Csla.Core.IParent&#39;.]


   System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +630


   System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1136


   System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +633


   Castle.Proxies.DefaultModelBinderProxy.BindModel_callback(ControllerContext controllerContext, ModelBindingContext bindingContext) +45


   Castle.Proxies.Invocations.DefaultModelBinder_BindModel.InvokeMethodOnTarget() +191


   Castle.DynamicProxy.AbstractInvocation.Proceed() +117

Tuesday, May 26, 2015  |  From VS Templates

I have this error "An asynchronous module or handler completed while an asynchronous operation was still pending" in my MVC 5 web application when deleting children from my model, via a grid which fires ajax requests to the MVC controller.


There is an async business rule on the parent, IsAsync = true and context.Complete is called when it Executes.


My delete signature in the MVC controller is (using a Kendo grid here);


public async Task<JsonResult> CustomerUser_Destroy([DataSourceRequest] DataSourceRequest request, AccountUserEdit record, int id)


and the content......


if (record != null)
               {
                   //get existing model(s)
                   var parentModel = AccountEdit.GetAccount(record.AccountId);
                   AccountUserEdit child = (from p in parentModel.CustomerAccountUsers
                                             where p.Id == id
                                             select p).First();


                    //delete it
                   parentModel.CustomerAccountUsers.Remove(child);


                    //can we save it
                   if (parentModel.IsSavable)
                   {
                       parentModel = await parentModel.SaveAsync(true);
                   }
                   else
                   {
                       //get broken rules message.
                       throw new ValidationException(MyBrokenRulesMessage.GetBrokenRules(parentModel, child));


                    }
               }
               return Json(ModelState.ToDataSourceResult());


I have this wrapped within a try catch exception block but the error is not being caught here.  


So the behavior to reproduce the error is that I can add some children in my MVC grid and they are saved ok.  If I then start removing them I get the error.  Oddly, if I refresh the browser page, and then delete a child it works.


Hard to track the error down.....so what am I doing wrong?


"An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


[InvalidOperationException: An asynchronous module or handler completed while an asynchronous operation was still pending.]


"


 


Any pointers appreciated.

Wednesday, May 20, 2015  |  From VS Templates


Spent a few hours yesterday making some big changes around .NET 4.6 and VS15.


In GitHub there's now a V4-5-x branch that will be used to maintain the existing 4.5 version of CSLA that uses VS13 and targets .NET 4.5, WinRT, Silverlight, etc.


The master branch in GitHub will be soon moving to VS15 to add support for .NET 4.6. This will also be version 4.6.x of CSLA.




I am explicitly dropping support for Silverlight and Windows Phone 7/8.


I have not decided yet if CSLA 4.6 will continue to support .NET 4 or 4.5. I'll make that determination as I work on .NET 4.6 support. My guess is that (at least for now) the changes will be minimal enough that I can retain support for 4 and 4.5.


If possible I plan to retain support for WinRT in CSLA 4.6, along with adding support for the Universal Windows Platform (UWP) for Windows 10 (PC, mobile, Xbox, etc.).


The start of this work is in GitHub in the rockfordlhotka/csla fork.



Tuesday, May 19, 2015  |  From VS Templates

I am after advice on 'life after Silverlight' (2021) and the preparation beforehand.


 


Scenario:


Sole developer (currently with 1 main commercial application (50 clients) (1 one other), using csla 4.5.3 and Silverlight, MS SQL)


 


My assumption is:


1) I will need to rewrite my application(s) to be ready around 10/12/2012 (I'm assuming there will be a 12-18 month time lag on this to take this date to say 10/21/2022)


 


Due to limited time between now and then I need to consider the above questions soon.


 


I would like to keep CSLA.net so am after advice on which development technology to use.


 


2) I am sure I will need a web-based solution (users are schools and teachers - ICT skills are poor (sorry teachers) and so I need a solution that can be deployed remotely without (minimal) user intervention)


 


3) I don't particularly like html (or should I say CSS), however at the age of 51 I would be prepared for one final push to learn/become expert at this.


 


I think some of you may suggest WPF as it is close to Silverlight - my concern is... can WPF be guaranteed to be strong post 2021.  I need a solution that is good for at least 15-20 years (my application is subscription based and will provide my pension to 65 and beyond - hopefully!! - hence why I am leaning to html5 etc.).


 


There are so many current frameworks etc. that I'm getting a little bogged down and confused.


 


I am thinking of using MVC6 (I've not done mvc before previously using win forms but not a lot and am happy to switch as I like the pattern [MVVM/MVC]) 


 


If I use MVC6 should I also learn Web API?  Is this a better fit for CSLA?


 


Which front end / binding framework?  Angular, Knockout etc and are these compatible with CSLA? - can these of other frameworks 'bind' to CSLA objects?


 


Any views on this would be warmly welcome - and I hope benefit others in this scenario.


 


One final thought might be to wait to say 2019 and hope that MS (or others) may have come up with a more streamlined (html) technology that is as good and as easy as Silverlight.

Monday, May 18, 2015  |  From VS Templates

I have converted the bulk of my Silverlight app to WFP without any significant issues, except for one that I would call a nightmare.  I realize it is not a Csla issue, but searching the internet I see lot of questions but no satisfactory answer.


In my SL application in the App.xaml I have quite a few Application Resources of the form:
           <vm:PlanViewModel x:Key="PlanData" />
where PlanData is then used as in DataContext=("{StaticResource PlanData}"). 


Problem comes when I try to enter that line in WPF App.xaml file.  When I enter <vm: the intelliSense promptly brings up my list of ViewModels in a drop down, where I can choose "PlanViewModel. But as soon as I finish the line by typing "/>"; an error condition tells me that there is no PlanViewModel in the very exact folder from which intelliSense had me select it!!  I have the proper reference to the ViewModel folder as an xmlns:vm line in App.xaml.


When I started with this conversion, I had the same problem with my Converters, like ItemVisibilityConverter.  That problem would suddenly appear after I brought in a few of my Page files. Once it appeared, the only solution was to drag everything to trash and start over.  Now for some reason all of that is okay.


I have struggled unsuccessfully to find an alternative to using the App.xaml for these resources but haven't been able to come up with anything satisfactory.  Would appreciate some help.


Javed


 

Friday, May 15, 2015  |  From VS Templates

I have a use case where i need to restrict a user when they are in a certain role to only edit "their own" record(s).


What's the best way of doing this?


I obviously know the user making the request and have/can load their roles up and if in this role, then check if the record belongs to them.  I'm thinking I can write this code in the DataPortal_Fetch method for example and throw a SecurityException.


Is that the best solution here?


The authorization rules are per type, so no help here unless we can still do some sort of per-instance rule?


Thanks.


Richard.

Thursday, May 14, 2015  |  From VS Templates

I'd like to see the ISerializationFormatter feature extended to allow applying my own implementation.  Being able to specify the type in the app.config/web.config similarly to how you provide a custom WcfProxy or DataPortalActivator would be perfect for me.  My current problem requires me to provide the BinaryFormatter with a custom SerializationBinder.  This feature would make this a lot easier.  Has this idea been tossed around at all?

Tuesday, May 12, 2015  |  From VS Templates

WinRT app with CSLA 4.5.601.0 running on devices with WWAN hitting a remote DP in the DMZ (acting as a pass through to an internal app server). We're seeing occasional errors related to connections being closed:


WebException: The underlying connection was closed: An unexpected error occurred on a receive.


SocketException: An existing connection was forcibly closed by the remote host


I see a lot of sites recommending setting HttpWebRequest.KeepAlive = false (default is true). I've not seen anything about this in the CSLA forum. Here's an MSDN post about it


Any thoughts on what the problem might be and whether this is something I should look into for our DP? Again, it is occasional, but occurs often enough that I'd like to figure out what the problem is, if possible.


Thanks,
Tim

 VS Templates News Feed 

Last edited Jan 18, 2007 at 6:55 PM by RockfordLhotka, version 2

Comments

No comments yet.