CSLA .NET Contrib News Feed 
Tuesday, September 16, 2014  |  From CSLA .NET Contrib

Hello everyone..


I have developed an application using csla.In viewmodel class,I have called Model.Save().But I'm getting the following error at Model.Save() in Wpf application.


Error - The remote server returned an unexpected response: (413) Request Entity Too Large.


But the same Model.Save() works fine in Silverlight application.


What could be the possible reason?Please suggest.

Monday, September 15, 2014  |  From CSLA .NET Contrib

Hello,


I have VS2012 and VS2013 installed. For the new CSLA project I installed nuget CSLA Templates version 4.5.601.


In VS 2012 all is ok but in VS2013 I do not see any snippets and csla item templates after nuget package installation. In the NuGet manager package has state: "this package is already installed".


Does anyone have any idea on how to solve it?



thank you







Monday, September 15, 2014  |  From CSLA .NET Contrib

I have a BO called Payment.


When a Customer makes a payment, I need to require that Customer to have a BillingAddress set, if it is an account payment.


However, I'm not sure how to do this in practice. What I have so far is shown below - it is throwing "given key not present in the dictionary". I can understand why. Really I just don't know if this is possible.


CODE:


private class ValidCustomerBusinessAddressRequiredForAccountPayments : BusinessRule


        {


            private readonly IBusinessRule _addressRequiredRule;


            private readonly IBusinessRule _addressCompletedRule;


            public ValidCustomerBusinessAddressRequiredForAccountPayments()


                : base(MethodProperty)


            {


                InputProperties = new List<IPropertyInfo> { MethodProperty };


                _addressRequiredRule = new Required(Customer.BillingAddressProperty);


                _addressCompletedRule = new FullAddressRule(Customer.BillingAddressProperty);


            }


            protected override void Execute(RuleContext context)


            {


                var target = (Payment)context.Target;


                var method = target.Method;


                var customer = Customer.Get(target.PrimaryContactId);


                if (customer != null && method == PaymentMethod.Account)


                {


                    context.ExecuteRule(_addressRequiredRule); // throws exception


                    context.ExecuteRule(_addressCompletedRule);


                }


            }


        }

Sunday, September 14, 2014  |  From CSLA .NET Contrib

It's my pleasure to announce CslaGenFork 4.5.0 was release today.


Targets:


  • CSLA 4.3.14 (NET 4.0, Silverlight 4 and Silverlight 5)
  • CSLA 4.5.600 (NET 4.0, NET 4.5 and Silverlight 5)

Data Portal models:


  • Encapsulated Implementation
  • Encapsulated Invoke using both variants of DAL, DataReader and DTO

New features since 4.3 release candidate:


  • Support for CSLA 4.5.x (and up) using synchronous DataPortal_XYZ methods
  • Support for new SQL Server 2008 date/time data types
  • Support for UTC
  • VB code generation (only Encapsulated Implementation)
  • Support for inline SQL queries
  • Global Settings panel for code and stored procedure encodings
  • Plus lots of improvements and fixes

Full release notes and download


https://cslagenfork.codeplex.com/releases/view/103667

Saturday, September 13, 2014  |  From CSLA .NET Contrib

Can I have multiple child properties for a single BusinessBase object?

Saturday, September 13, 2014  |  From CSLA .NET Contrib

Hi,


I'm having an issue when I'm using the Async dataPortal methods (FetchAsync(), etc...) at the same time as using a Local Server DataPortal




 public async Task Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
    {
      if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server)
      {
        return await _portal.Fetch(objectType, criteria, context, isSync);
      }
      else
      {
        var tcs = new TaskCompletionSource();
        var bw = new Csla.Threading.BackgroundWorker();
        bw.DoWork += (s, o) =>
        {
          o.Result = _portal.Fetch(objectType, criteria, context, isSync).Result;
        };
        bw.RunWorkerCompleted += (s, o) =>
        {
          if (o.Error == null)
            tcs.TrySetResult((DataPortalResult)o.Result);
          else
            tcs.TrySetException(o.Error);
        };
        bw.RunWorkerAsync();
        return await tcs.Task;
      }
    }



In my case I'm always falling the in "else" block which seems to dead lock on the ".Result" which for some reason never completes


I just don't get the else block and why this method cannot use the code inside the "if" block all the time.


When I change the code to always enter the "if" block no more dead lock.  

Friday, September 12, 2014  |  From CSLA .NET Contrib

Hello...


I have written a BO class viz. PersonEdit. It has PersonAddresses & PersonPhones as child properties.


Each address or phone may have tags such as Home,Office,School.


The following DataPortal_Create() code runs successfully in Silverlight. But in wpf, it doesn't work. Can anyone tell me the reason behind it. 


protected override void DataPortal_Create()
        {
            PersonAddressesEditList addressList = new PersonAddressesEditList();
            foreach (var addressTag in AddressTagNVList.GetList())
            {
                PersonAddressEdit obj = DataPortal.CreateChild<PersonAddressEdit>(this.Id);
                obj.AddressTagId = addressTag.Key;
                obj.AddressTagDescription = addressTag.Value;
                obj.ShareUnshareContent = "Share";
                addressList.Add(obj);
            }
            PersonPhonesEditList phoneList = new PersonPhonesEditList();
            foreach (var phoneTag in PhoneTagNVList.GetList())
            {
                PersonPhoneEdit obj = DataPortal.CreateChild<PersonPhoneEdit>(this.Id);
                obj.PhoneTagId = phoneTag.Key;
                obj.PhoneTagDescription = phoneTag.Value;
                obj.ShareUnshareContent = "Share";
                phoneList.Add(obj);
            }
            SetProperty(PersonAddressesProperty,addressList);
            SetProperty(PersonPhonesProperty,phoneList);
            base.DataPortal_Create();
        }


For WPF,If I comment this code, then the Person object is saved.

Tuesday, September 09, 2014  |  From CSLA .NET Contrib

I receive this error when I deploy to a shared hosting server at godaddy. I do not get this error on localhost or deployed to development server. Any ideas?


 


Inheritance security rules violated while overriding
member:
'Csla.Server.DataPortalException.GetObjectData(System.Runtime.Serialization.SerializationInfo,
System.Runtime.Serialization.StreamingContext)'. Security accessibility
of the overriding method must match the security accessibility of the
method being overriden.




Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.



Exception Details: System.TypeLoadException:
Inheritance security rules violated while overriding member:
'Csla.Server.DataPortalException.GetObjectData(System.Runtime.Serialization.SerializationInfo,
System.Runtime.Serialization.StreamingContext)'. Security accessibility
of the overriding method must match the security accessibility of the
method being overriden.


Source Error:










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.




Stack Trace:










[TypeLoadException: Inheritance security rules violated while overriding member: 'Csla.Server.DataPortalException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.]
   Csla.DataPortal.Fetch(Type objectType, Object criteria) +0
   Csla.DataPortal.Fetch(Object criteria) +56
   QSLDL.CountryList.GetAll() in CountryList.Generated.cs:84
   Default.LoadForm() in Default.aspx.cs:35
   Default.Page_Load(Object sender, EventArgs e) in Default.aspx.cs:21
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772


Tuesday, September 09, 2014  |  From CSLA .NET Contrib

I often find that there's a need to do authorization not just based on the user's roles (permissions), but also based on some state in the object itself.  A common scenario is only the creator of a particular object can edit it (but they can be viewed by all).  Or a property value should only be allowed to be changed if the Status property is a certain value. 


The Target property of the AuthorizationContext would seem to allow access to any object state, but I want to verify if that is the proper way to access the state or not.


I found a thread from a while back that discussed sending input property values into authorization rules, and also allowing the rule to specify if its result may be cached, but nothing seems to have come of those.


Any suggestions (which ideally don't involve overriding CanWriteProperty)?

Tuesday, September 09, 2014  |  From CSLA .NET Contrib

Hello, I'm using CSLA 3.6 and I have some business rules in my business base object that claim to clean some fields when I change a property. These fields have business rules related with them so, when I'm restoring their value in my set propery, I'm using PropertyHasChanged(field_name).


If I have a lot of fields for restore to initial values, time to successfully run my entire Set property code is growing. How can I obtain this without time issues?


 


Thanks in advance, Marian  


 

Sunday, September 07, 2014  |  From CSLA .NET Contrib

Hi Rocky,


Updating to Csla .NET 4.5.601 some .NET 4.0 projects under VS2010, I got plenty of errors and I could understand why. I migrated one of these projects to VS2012 and got the following error:


C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "Csla" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.2.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Csla" or retarget your application to a framework version which contains "System.Net.Http, Version=2.2.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".


The important part is this one:


The primary reference "Csla" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.2.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework.


It looks like you can compile CSLA to target framework 4 but you can't use the compiled result on framework 4 projects. I must add the projects are using framework 4 Client Profile. I tryed the full profile and got the same result.


Can this be fixed?

Thursday, September 04, 2014  |  From CSLA .NET Contrib

Context : NET 4.5 / SL 5 / Csla: 4.5.601.0 / IIS: 7.5 / OS: Win7


Hi everyone,


I am currently experiencing a problem getting windows authentication working correctly with the Silverlight application demo.  Actually, since I have upgraded the CSLA  assembly from 4.5.501 to 4.6.501, the PopulateWindowsIdentity function return the WindowsIdentity from the  application pool identity (IIS) instead of Windows account user.


The same SL application works just fine if I used the CSLA  assembly 4.5.501


About the IIS configuration, i have sent a post several month ago.http://forums.lhotka.net/forums/t/12036.aspx


Is someone have already faced the issue or found something about it ?


Thx for your help in advance.


Cedric

Tuesday, September 02, 2014  |  From CSLA .NET Contrib

Hi Guys,


 


I am new to this forum and also CSLA.NET. I was wondering if there is a way in CSLA to impersonate a different user when making SQL calls. I want all my sql statements to be executed under a specific user account. Any help will me much appreciated.


 


Regards


 


Toshan

Saturday, August 30, 2014  |  From CSLA .NET Contrib

Hi everybody.


I'm invoking public factory methods using Csla Reflection, and came across a particular case where


public static object CallFactoryMethod(Type objectType, string method, params object[] parameters)
{
  object returnValue;
  MethodInfo factory = objectType.GetMethod(method, factoryFlags, null
MethodCaller.GetParameterTypes(parameters), null);
 
 if (factory == null)
....

presents an issue when it calls [MethodCaller.GetParameterTypes(parameters)] and [parameters] is null.


When [GetParameterTypes(null) is executed, it adds [result.Add(typeof(object));] to the result [type] list.


public static Type[] GetParameterTypes(object[] parameters)
{
List<Type> result = new List<Type>();

if (parameters == null)
{
result.Add(typeof(object));
}
else



I have a particular case where I define 2 public static methods on a class like this:


1. public static NewObject() {...}


2. public static NewObject(object obj} {...}



By default, when I try to Invoke the 1st. method with no parameters, CallFactoryMethod(..) with [null] as params[], it defaults to the 2nd. version of the method, due to its default parameter added by GetParameterTypes(..).


And it throws an exception because I'm not sending the [object] parameter, instead, I'm sending null as params.


I didn't get to check the implications of changing this behaviour on CSLA.


If anyone can suggest a simple workaround, it's welcome.


For now I'll use my own Reflection Functions to call on this factory methods for NewObject on my BOs.


Thanks to all,


Troncho


Wednesday, August 27, 2014  |  From CSLA .NET Contrib

We're looking at continuous integration tools for our in-house .NET and ASP.NET applications. In addition to the code, we also would like to update both schema and configuration data in our SQL Server database. Curious to know what others from this community have chosen and how they like their choice.


At this point, we're looking at CruiseControl.Net, Jenkins, TeamCity, and a strictly TFS solution using the Release Management functionality (which seems very expensive).


Thanks for your input.

Monday, August 25, 2014  |  From CSLA .NET Contrib

Hello,


I am reading the CSLA ebook and in the DataAccess ebook (page 114) are mentioned objects as SkillEditList, SkillEdit and library Library.Net and solution EncapsulatedInvoke, EncapsulatedInvokeDto ...


Or DataAccess.Mock, DataAccess.SqlCe, and DataAccess.SqlEf projects


Please could you advise, where can I download mentioned code sample.


In the samples dir of CSLA 4.1 version I am not able to find it.


Thank you

Saturday, August 23, 2014  |  From CSLA .NET Contrib

Wouldn't be better if the Value property in FieldData only set the IsDirty flag to 'true' when the new value was different  from the old value?


Cause the class uses generics, I've made the change as below:


        public virtual T Value


        {


            get


            {


                return _data;


            }


            set


            {


                if (_data == null && value == null)


                    return;


                if ((_data != null && !_data.Equals(value)) || 


                    (value != null && !value.Equals(_data)))


                {


                    _data = value;


                    _isDirty = true;


                }


            }


        }

Friday, August 22, 2014  |  From CSLA .NET Contrib

Please, correct me if I'm wrong, but FieldDataManager.UpdateChildren shouldn't be like this:


        public void UpdateChildren(params object[] parameters)


        {


            if (_propertyList == null) return;


            foreach (var pi in _propertyList)


            {


                if ((pi.RelationshipType & RelationshipTypes.Child) > 0)


                {


                    var item = _fieldData[pi.Index];


                    if (item != null)


                    {


                        object obj = item.Value;


                        if (obj is IEditableBusinessObject || obj is IEditableCollection)


                            Csla.DataPortal.UpdateChild(obj, parameters);


                    }


                }


            }


        }


The way it is now, all objects referenced by the businessobject are being treated as children even when they aren't.

Wednesday, August 20, 2014  |  From CSLA .NET Contrib

I am in the process of setting up Automated Tests using MSTest.  I would like to create a Mock DAL for the Test project.  The WPF app loads the DAL based on the appSettings tags in the App.Config file (CslaDataPortalProxy, ObjectFactoryAssembly, CslaObjectFactoryLoader).


The MSTest project does not have an app.config file so how I can point that project to the Mock DAL?


 


Using CSLA 4.5.501 and Visual Studio 2013.

Tuesday, August 19, 2014  |  From CSLA .NET Contrib

Hi,


This morning I was upgrading CSLA 4.3 to 4.5 and when I ran our application, anything using a ReadOnlyList failed in the DataPortal_Fetch.  I finally found the answer in this thread: http://forums.lhotka.net/forums/p/12449/56992.aspx


OK, easy fix alright.  Except than I ran into some slightly different fetch code.  My boss had been working on making a data loader use threads to speed up the process.  But on occasion, it would fail because a thread could be trying to read a list while one was writing to it (can't remember the exact details, as I wasn't directly working on this).  So we have a number of lists where the DataPortal_Fetch does this:


while (dataReader.Read())
{
    currentObject = Word.GetWord(dataReader);
    lock (loadingLock)
    {
        this.Add(currentObject);
    }
}

I'm trying to figure out whether I should put the "this.ReadOnly = false" and "... = true" code inside the lock, outside the lock but inside the while, or before/after the while.


Or is the above a big no-no to begin with?


Thanks,
Michel 

 CSLA .NET Contrib News Feed 

 Code-gen Templates News Feed 
Sunday, September 14, 2014  |  From Code-gen Templates

It's my pleasure to announce CslaGenFork 4.5.0 was release today.


Targets:


  • CSLA 4.3.14 (NET 4.0, Silverlight 4 and Silverlight 5)
  • CSLA 4.5.600 (NET 4.0, NET 4.5 and Silverlight 5)

Data Portal models:


  • Encapsulated Implementation
  • Encapsulated Invoke using both variants of DAL, DataReader and DTO

New features since 4.3 release candidate:


  • Support for CSLA 4.5.x (and up) using synchronous DataPortal_XYZ methods
  • Support for new SQL Server 2008 date/time data types
  • Support for UTC
  • VB code generation (only Encapsulated Implementation)
  • Support for inline SQL queries
  • Global Settings panel for code and stored procedure encodings
  • Plus lots of improvements and fixes

Full release notes and download


https://cslagenfork.codeplex.com/releases/view/103667

Saturday, September 13, 2014  |  From Code-gen Templates

Can I have multiple child properties for a single BusinessBase object?

Saturday, September 13, 2014  |  From Code-gen Templates

Hi,


I'm having an issue when I'm using the Async dataPortal methods (FetchAsync(), etc...) at the same time as using a Local Server DataPortal




 public async Task Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
    {
      if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server)
      {
        return await _portal.Fetch(objectType, criteria, context, isSync);
      }
      else
      {
        var tcs = new TaskCompletionSource();
        var bw = new Csla.Threading.BackgroundWorker();
        bw.DoWork += (s, o) =>
        {
          o.Result = _portal.Fetch(objectType, criteria, context, isSync).Result;
        };
        bw.RunWorkerCompleted += (s, o) =>
        {
          if (o.Error == null)
            tcs.TrySetResult((DataPortalResult)o.Result);
          else
            tcs.TrySetException(o.Error);
        };
        bw.RunWorkerAsync();
        return await tcs.Task;
      }
    }



In my case I'm always falling the in "else" block which seems to dead lock on the ".Result" which for some reason never completes


I just don't get the else block and why this method cannot use the code inside the "if" block all the time.


When I change the code to always enter the "if" block no more dead lock.  

Friday, September 12, 2014  |  From Code-gen Templates

Hello...


I have written a BO class viz. PersonEdit. It has PersonAddresses & PersonPhones as child properties.


Each address or phone may have tags such as Home,Office,School.


The following DataPortal_Create() code runs successfully in Silverlight. But in wpf, it doesn't work. Can anyone tell me the reason behind it. 


protected override void DataPortal_Create()
        {
            PersonAddressesEditList addressList = new PersonAddressesEditList();
            foreach (var addressTag in AddressTagNVList.GetList())
            {
                PersonAddressEdit obj = DataPortal.CreateChild<PersonAddressEdit>(this.Id);
                obj.AddressTagId = addressTag.Key;
                obj.AddressTagDescription = addressTag.Value;
                obj.ShareUnshareContent = "Share";
                addressList.Add(obj);
            }
            PersonPhonesEditList phoneList = new PersonPhonesEditList();
            foreach (var phoneTag in PhoneTagNVList.GetList())
            {
                PersonPhoneEdit obj = DataPortal.CreateChild<PersonPhoneEdit>(this.Id);
                obj.PhoneTagId = phoneTag.Key;
                obj.PhoneTagDescription = phoneTag.Value;
                obj.ShareUnshareContent = "Share";
                phoneList.Add(obj);
            }
            SetProperty(PersonAddressesProperty,addressList);
            SetProperty(PersonPhonesProperty,phoneList);
            base.DataPortal_Create();
        }


For WPF,If I comment this code, then the Person object is saved.

Tuesday, September 09, 2014  |  From Code-gen Templates

I receive this error when I deploy to a shared hosting server at godaddy. I do not get this error on localhost or deployed to development server. Any ideas?


 


Inheritance security rules violated while overriding
member:
'Csla.Server.DataPortalException.GetObjectData(System.Runtime.Serialization.SerializationInfo,
System.Runtime.Serialization.StreamingContext)'. Security accessibility
of the overriding method must match the security accessibility of the
method being overriden.




Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.



Exception Details: System.TypeLoadException:
Inheritance security rules violated while overriding member:
'Csla.Server.DataPortalException.GetObjectData(System.Runtime.Serialization.SerializationInfo,
System.Runtime.Serialization.StreamingContext)'. Security accessibility
of the overriding method must match the security accessibility of the
method being overriden.


Source Error:










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.




Stack Trace:










[TypeLoadException: Inheritance security rules violated while overriding member: 'Csla.Server.DataPortalException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.]
   Csla.DataPortal.Fetch(Type objectType, Object criteria) +0
   Csla.DataPortal.Fetch(Object criteria) +56
   QSLDL.CountryList.GetAll() in CountryList.Generated.cs:84
   Default.LoadForm() in Default.aspx.cs:35
   Default.Page_Load(Object sender, EventArgs e) in Default.aspx.cs:21
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772


Tuesday, September 09, 2014  |  From Code-gen Templates

I often find that there's a need to do authorization not just based on the user's roles (permissions), but also based on some state in the object itself.  A common scenario is only the creator of a particular object can edit it (but they can be viewed by all).  Or a property value should only be allowed to be changed if the Status property is a certain value. 


The Target property of the AuthorizationContext would seem to allow access to any object state, but I want to verify if that is the proper way to access the state or not.


I found a thread from a while back that discussed sending input property values into authorization rules, and also allowing the rule to specify if its result may be cached, but nothing seems to have come of those.


Any suggestions (which ideally don't involve overriding CanWriteProperty)?

Tuesday, September 09, 2014  |  From Code-gen Templates

Hello, I'm using CSLA 3.6 and I have some business rules in my business base object that claim to clean some fields when I change a property. These fields have business rules related with them so, when I'm restoring their value in my set propery, I'm using PropertyHasChanged(field_name).


If I have a lot of fields for restore to initial values, time to successfully run my entire Set property code is growing. How can I obtain this without time issues?


 


Thanks in advance, Marian  


 

Sunday, September 07, 2014  |  From Code-gen Templates

Hi Rocky,


Updating to Csla .NET 4.5.601 some .NET 4.0 projects under VS2010, I got plenty of errors and I could understand why. I migrated one of these projects to VS2012 and got the following error:


C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "Csla" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.2.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Csla" or retarget your application to a framework version which contains "System.Net.Http, Version=2.2.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".


The important part is this one:


The primary reference "Csla" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.2.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework.


It looks like you can compile CSLA to target framework 4 but you can't use the compiled result on framework 4 projects. I must add the projects are using framework 4 Client Profile. I tryed the full profile and got the same result.


Can this be fixed?

Thursday, September 04, 2014  |  From Code-gen Templates

Context : NET 4.5 / SL 5 / Csla: 4.5.601.0 / IIS: 7.5 / OS: Win7


Hi everyone,


I am currently experiencing a problem getting windows authentication working correctly with the Silverlight application demo.  Actually, since I have upgraded the CSLA  assembly from 4.5.501 to 4.6.501, the PopulateWindowsIdentity function return the WindowsIdentity from the  application pool identity (IIS) instead of Windows account user.


The same SL application works just fine if I used the CSLA  assembly 4.5.501


About the IIS configuration, i have sent a post several month ago.http://forums.lhotka.net/forums/t/12036.aspx


Is someone have already faced the issue or found something about it ?


Thx for your help in advance.


Cedric

Tuesday, September 02, 2014  |  From Code-gen Templates

Hi Guys,


 


I am new to this forum and also CSLA.NET. I was wondering if there is a way in CSLA to impersonate a different user when making SQL calls. I want all my sql statements to be executed under a specific user account. Any help will me much appreciated.


 


Regards


 


Toshan

Saturday, August 30, 2014  |  From Code-gen Templates

Hi everybody.


I'm invoking public factory methods using Csla Reflection, and came across a particular case where


public static object CallFactoryMethod(Type objectType, string method, params object[] parameters)
{
  object returnValue;
  MethodInfo factory = objectType.GetMethod(method, factoryFlags, null
MethodCaller.GetParameterTypes(parameters), null);
 
 if (factory == null)
....

presents an issue when it calls [MethodCaller.GetParameterTypes(parameters)] and [parameters] is null.


When [GetParameterTypes(null) is executed, it adds [result.Add(typeof(object));] to the result [type] list.


public static Type[] GetParameterTypes(object[] parameters)
{
List<Type> result = new List<Type>();

if (parameters == null)
{
result.Add(typeof(object));
}
else



I have a particular case where I define 2 public static methods on a class like this:


1. public static NewObject() {...}


2. public static NewObject(object obj} {...}



By default, when I try to Invoke the 1st. method with no parameters, CallFactoryMethod(..) with [null] as params[], it defaults to the 2nd. version of the method, due to its default parameter added by GetParameterTypes(..).


And it throws an exception because I'm not sending the [object] parameter, instead, I'm sending null as params.


I didn't get to check the implications of changing this behaviour on CSLA.


If anyone can suggest a simple workaround, it's welcome.


For now I'll use my own Reflection Functions to call on this factory methods for NewObject on my BOs.


Thanks to all,


Troncho


Wednesday, August 27, 2014  |  From Code-gen Templates

We're looking at continuous integration tools for our in-house .NET and ASP.NET applications. In addition to the code, we also would like to update both schema and configuration data in our SQL Server database. Curious to know what others from this community have chosen and how they like their choice.


At this point, we're looking at CruiseControl.Net, Jenkins, TeamCity, and a strictly TFS solution using the Release Management functionality (which seems very expensive).


Thanks for your input.

Monday, August 25, 2014  |  From Code-gen Templates

Hello,


I am reading the CSLA ebook and in the DataAccess ebook (page 114) are mentioned objects as SkillEditList, SkillEdit and library Library.Net and solution EncapsulatedInvoke, EncapsulatedInvokeDto ...


Or DataAccess.Mock, DataAccess.SqlCe, and DataAccess.SqlEf projects


Please could you advise, where can I download mentioned code sample.


In the samples dir of CSLA 4.1 version I am not able to find it.


Thank you

Saturday, August 23, 2014  |  From Code-gen Templates

Wouldn't be better if the Value property in FieldData only set the IsDirty flag to 'true' when the new value was different  from the old value?


Cause the class uses generics, I've made the change as below:


        public virtual T Value


        {


            get


            {


                return _data;


            }


            set


            {


                if (_data == null && value == null)


                    return;


                if ((_data != null && !_data.Equals(value)) || 


                    (value != null && !value.Equals(_data)))


                {


                    _data = value;


                    _isDirty = true;


                }


            }


        }

Friday, August 22, 2014  |  From Code-gen Templates

Please, correct me if I'm wrong, but FieldDataManager.UpdateChildren shouldn't be like this:


        public void UpdateChildren(params object[] parameters)


        {


            if (_propertyList == null) return;


            foreach (var pi in _propertyList)


            {


                if ((pi.RelationshipType & RelationshipTypes.Child) > 0)


                {


                    var item = _fieldData[pi.Index];


                    if (item != null)


                    {


                        object obj = item.Value;


                        if (obj is IEditableBusinessObject || obj is IEditableCollection)


                            Csla.DataPortal.UpdateChild(obj, parameters);


                    }


                }


            }


        }


The way it is now, all objects referenced by the businessobject are being treated as children even when they aren't.

Wednesday, August 20, 2014  |  From Code-gen Templates

I am in the process of setting up Automated Tests using MSTest.  I would like to create a Mock DAL for the Test project.  The WPF app loads the DAL based on the appSettings tags in the App.Config file (CslaDataPortalProxy, ObjectFactoryAssembly, CslaObjectFactoryLoader).


The MSTest project does not have an app.config file so how I can point that project to the Mock DAL?


 


Using CSLA 4.5.501 and Visual Studio 2013.

Tuesday, August 19, 2014  |  From Code-gen Templates

Hi,


This morning I was upgrading CSLA 4.3 to 4.5 and when I ran our application, anything using a ReadOnlyList failed in the DataPortal_Fetch.  I finally found the answer in this thread: http://forums.lhotka.net/forums/p/12449/56992.aspx


OK, easy fix alright.  Except than I ran into some slightly different fetch code.  My boss had been working on making a data loader use threads to speed up the process.  But on occasion, it would fail because a thread could be trying to read a list while one was writing to it (can't remember the exact details, as I wasn't directly working on this).  So we have a number of lists where the DataPortal_Fetch does this:


while (dataReader.Read())
{
    currentObject = Word.GetWord(dataReader);
    lock (loadingLock)
    {
        this.Add(currentObject);
    }
}

I'm trying to figure out whether I should put the "this.ReadOnly = false" and "... = true" code inside the lock, outside the lock but inside the while, or before/after the while.


Or is the above a big no-no to begin with?


Thanks,
Michel 

Monday, August 18, 2014  |  From Code-gen Templates

Can anyone save some of my hair? :)


I'm trying to create an asp.net WEB API interface for an older CSLA project.  I am testing by hard coding the login on every request in various ways (once in the startup code, as an authorization request filter, inside the individual route request etc etc).  All the ways I tried work exactly once perfectly and then I get the infamous:


'Default principal object cannot be set twice.'


exception in BusinessPrincipal.vb (yeah I know it's very old, but it's released software, I can't upgrade CSLA)


I know that there is an issue where you need to set HttpContext.Current.User = Thread.CurrentPrincipal; due to some internal workings of the web API and I do that already, that has not resolved the issue.


I'd like to know if anyone has implemented a web api front end and how they handled this issue or any pointers as to what could be the solution.

Sunday, August 17, 2014  |  From Code-gen Templates

Hi all,


I am currently evaluating whether to use CSLA in my project.


I'm also new to Xamarin. The plan is to develop for iOS and Android initially.


I have successfully added the Android and iOS CSLA nuget packages to my Xamarin solution but am stuck on adding the CSLA Core package to my PCL project. I get this error


Adding CSLA-Core...


Adding 'CSLA-Core 4.5.601' to MyProject.Domain.


Could not install package 'CSLA-Core 4.5.601'. You are trying to install this package into a project that targets 'portable-net45+win+wp80+MonoAndroid10+MonoTouch10', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.


I then tried creating a Shared project and putting my domain code in there and it seems to work.


Is anyone else doing this? Is this the correct approach?


Thanks,


Jonathan.


P.S. I'm excited about using CSLA and Xamarin for the first time.

Friday, August 15, 2014  |  From Code-gen Templates

I have a ton of working objects in a WinRT app and have followed the same pattern for all of them. But with a new one I've created, I get the following exception when executing an async Fetch method on a list object.


System.Reflection.AmbiguousMatchException


This occurs when I try to do this:


        public static async Task<ProductCategorySalesInfoList> GetListAsync()
        {
               return await DataPortal.FetchAsync<ProductCategorySalesInfoList>();
        } 


I feel like I've probably missed something somewhere, but can't seem to find it. The stack trace for the inner error of the ErrorInfo object is as follows. Any ideas on where to look or what to look for? Thanks.


 


   at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)   at System.Type.GetMethod(String name, BindingFlags bindingAttr)   at Csla.Reflection.MethodCaller.GetMethod(Type objectType, String method, Boolean hasParameters, Object[] parameters)   at Csla.Reflection.MethodCaller.GetMethod(Type objectType, String method, Object[] parameters)   at Csla.Server.DataPortalMethodCache.GetMethodInfo(Type objectType, String methodName, Object[] parameters)   at Csla.Server.DataPortalMethodCache.GetFetchMethod(Type objectType, Object criteria)   at Csla.DataPortal'1.<DoFetchAsync>d__11.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult()   at Csla.DataPortal'1.<FetchAsync>d__1b.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult()   at Csla.DataPortal.<FetchAsync>d__c'1.MoveNext() 

 Code-gen Templates News Feed 

 VS Templates News Feed 
Monday, September 15, 2014  |  From VS Templates

Hello,


I have VS2012 and VS2013 installed. For the new CSLA project I installed nuget CSLA Templates version 4.5.601.


In VS 2012 all is ok but in VS2013 I do not see any snippets and csla item templates after nuget package installation. In the NuGet manager package has state: "this package is already installed".


Does anyone have any idea on how to solve it?



thank you







Monday, September 15, 2014  |  From VS Templates

I have a BO called Payment.


When a Customer makes a payment, I need to require that Customer to have a BillingAddress set, if it is an account payment.


However, I'm not sure how to do this in practice. What I have so far is shown below - it is throwing "given key not present in the dictionary". I can understand why. Really I just don't know if this is possible.


CODE:


private class ValidCustomerBusinessAddressRequiredForAccountPayments : BusinessRule


        {


            private readonly IBusinessRule _addressRequiredRule;


            private readonly IBusinessRule _addressCompletedRule;


            public ValidCustomerBusinessAddressRequiredForAccountPayments()


                : base(MethodProperty)


            {


                InputProperties = new List<IPropertyInfo> { MethodProperty };


                _addressRequiredRule = new Required(Customer.BillingAddressProperty);


                _addressCompletedRule = new FullAddressRule(Customer.BillingAddressProperty);


            }


            protected override void Execute(RuleContext context)


            {


                var target = (Payment)context.Target;


                var method = target.Method;


                var customer = Customer.Get(target.PrimaryContactId);


                if (customer != null && method == PaymentMethod.Account)


                {


                    context.ExecuteRule(_addressRequiredRule); // throws exception


                    context.ExecuteRule(_addressCompletedRule);


                }


            }


        }

Sunday, September 14, 2014  |  From VS Templates

It's my pleasure to announce CslaGenFork 4.5.0 was release today.


Targets:


  • CSLA 4.3.14 (NET 4.0, Silverlight 4 and Silverlight 5)
  • CSLA 4.5.600 (NET 4.0, NET 4.5 and Silverlight 5)

Data Portal models:


  • Encapsulated Implementation
  • Encapsulated Invoke using both variants of DAL, DataReader and DTO

New features since 4.3 release candidate:


  • Support for CSLA 4.5.x (and up) using synchronous DataPortal_XYZ methods
  • Support for new SQL Server 2008 date/time data types
  • Support for UTC
  • VB code generation (only Encapsulated Implementation)
  • Support for inline SQL queries
  • Global Settings panel for code and stored procedure encodings
  • Plus lots of improvements and fixes

Full release notes and download


https://cslagenfork.codeplex.com/releases/view/103667

Saturday, September 13, 2014  |  From VS Templates

Can I have multiple child properties for a single BusinessBase object?

Saturday, September 13, 2014  |  From VS Templates

Hi,


I'm having an issue when I'm using the Async dataPortal methods (FetchAsync(), etc...) at the same time as using a Local Server DataPortal




 public async Task Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
    {
      if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server)
      {
        return await _portal.Fetch(objectType, criteria, context, isSync);
      }
      else
      {
        var tcs = new TaskCompletionSource();
        var bw = new Csla.Threading.BackgroundWorker();
        bw.DoWork += (s, o) =>
        {
          o.Result = _portal.Fetch(objectType, criteria, context, isSync).Result;
        };
        bw.RunWorkerCompleted += (s, o) =>
        {
          if (o.Error == null)
            tcs.TrySetResult((DataPortalResult)o.Result);
          else
            tcs.TrySetException(o.Error);
        };
        bw.RunWorkerAsync();
        return await tcs.Task;
      }
    }



In my case I'm always falling the in "else" block which seems to dead lock on the ".Result" which for some reason never completes


I just don't get the else block and why this method cannot use the code inside the "if" block all the time.


When I change the code to always enter the "if" block no more dead lock.  

Friday, September 12, 2014  |  From VS Templates

Hello...


I have written a BO class viz. PersonEdit. It has PersonAddresses & PersonPhones as child properties.


Each address or phone may have tags such as Home,Office,School.


The following DataPortal_Create() code runs successfully in Silverlight. But in wpf, it doesn't work. Can anyone tell me the reason behind it. 


protected override void DataPortal_Create()
        {
            PersonAddressesEditList addressList = new PersonAddressesEditList();
            foreach (var addressTag in AddressTagNVList.GetList())
            {
                PersonAddressEdit obj = DataPortal.CreateChild<PersonAddressEdit>(this.Id);
                obj.AddressTagId = addressTag.Key;
                obj.AddressTagDescription = addressTag.Value;
                obj.ShareUnshareContent = "Share";
                addressList.Add(obj);
            }
            PersonPhonesEditList phoneList = new PersonPhonesEditList();
            foreach (var phoneTag in PhoneTagNVList.GetList())
            {
                PersonPhoneEdit obj = DataPortal.CreateChild<PersonPhoneEdit>(this.Id);
                obj.PhoneTagId = phoneTag.Key;
                obj.PhoneTagDescription = phoneTag.Value;
                obj.ShareUnshareContent = "Share";
                phoneList.Add(obj);
            }
            SetProperty(PersonAddressesProperty,addressList);
            SetProperty(PersonPhonesProperty,phoneList);
            base.DataPortal_Create();
        }


For WPF,If I comment this code, then the Person object is saved.

Tuesday, September 09, 2014  |  From VS Templates

I receive this error when I deploy to a shared hosting server at godaddy. I do not get this error on localhost or deployed to development server. Any ideas?


 


Inheritance security rules violated while overriding
member:
'Csla.Server.DataPortalException.GetObjectData(System.Runtime.Serialization.SerializationInfo,
System.Runtime.Serialization.StreamingContext)'. Security accessibility
of the overriding method must match the security accessibility of the
method being overriden.




Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.



Exception Details: System.TypeLoadException:
Inheritance security rules violated while overriding member:
'Csla.Server.DataPortalException.GetObjectData(System.Runtime.Serialization.SerializationInfo,
System.Runtime.Serialization.StreamingContext)'. Security accessibility
of the overriding method must match the security accessibility of the
method being overriden.


Source Error:










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.




Stack Trace:










[TypeLoadException: Inheritance security rules violated while overriding member: 'Csla.Server.DataPortalException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.]
   Csla.DataPortal.Fetch(Type objectType, Object criteria) +0
   Csla.DataPortal.Fetch(Object criteria) +56
   QSLDL.CountryList.GetAll() in CountryList.Generated.cs:84
   Default.LoadForm() in Default.aspx.cs:35
   Default.Page_Load(Object sender, EventArgs e) in Default.aspx.cs:21
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772


Tuesday, September 09, 2014  |  From VS Templates

I often find that there's a need to do authorization not just based on the user's roles (permissions), but also based on some state in the object itself.  A common scenario is only the creator of a particular object can edit it (but they can be viewed by all).  Or a property value should only be allowed to be changed if the Status property is a certain value. 


The Target property of the AuthorizationContext would seem to allow access to any object state, but I want to verify if that is the proper way to access the state or not.


I found a thread from a while back that discussed sending input property values into authorization rules, and also allowing the rule to specify if its result may be cached, but nothing seems to have come of those.


Any suggestions (which ideally don't involve overriding CanWriteProperty)?

Tuesday, September 09, 2014  |  From VS Templates

Hello, I'm using CSLA 3.6 and I have some business rules in my business base object that claim to clean some fields when I change a property. These fields have business rules related with them so, when I'm restoring their value in my set propery, I'm using PropertyHasChanged(field_name).


If I have a lot of fields for restore to initial values, time to successfully run my entire Set property code is growing. How can I obtain this without time issues?


 


Thanks in advance, Marian  


 

Sunday, September 07, 2014  |  From VS Templates

Hi Rocky,


Updating to Csla .NET 4.5.601 some .NET 4.0 projects under VS2010, I got plenty of errors and I could understand why. I migrated one of these projects to VS2012 and got the following error:


C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "Csla" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.2.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Csla" or retarget your application to a framework version which contains "System.Net.Http, Version=2.2.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".


The important part is this one:


The primary reference "Csla" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.2.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework.


It looks like you can compile CSLA to target framework 4 but you can't use the compiled result on framework 4 projects. I must add the projects are using framework 4 Client Profile. I tryed the full profile and got the same result.


Can this be fixed?

Thursday, September 04, 2014  |  From VS Templates

Context : NET 4.5 / SL 5 / Csla: 4.5.601.0 / IIS: 7.5 / OS: Win7


Hi everyone,


I am currently experiencing a problem getting windows authentication working correctly with the Silverlight application demo.  Actually, since I have upgraded the CSLA  assembly from 4.5.501 to 4.6.501, the PopulateWindowsIdentity function return the WindowsIdentity from the  application pool identity (IIS) instead of Windows account user.


The same SL application works just fine if I used the CSLA  assembly 4.5.501


About the IIS configuration, i have sent a post several month ago.http://forums.lhotka.net/forums/t/12036.aspx


Is someone have already faced the issue or found something about it ?


Thx for your help in advance.


Cedric

Tuesday, September 02, 2014  |  From VS Templates

Hi Guys,


 


I am new to this forum and also CSLA.NET. I was wondering if there is a way in CSLA to impersonate a different user when making SQL calls. I want all my sql statements to be executed under a specific user account. Any help will me much appreciated.


 


Regards


 


Toshan

Saturday, August 30, 2014  |  From VS Templates

Hi everybody.


I'm invoking public factory methods using Csla Reflection, and came across a particular case where


public static object CallFactoryMethod(Type objectType, string method, params object[] parameters)
{
  object returnValue;
  MethodInfo factory = objectType.GetMethod(method, factoryFlags, null
MethodCaller.GetParameterTypes(parameters), null);
 
 if (factory == null)
....

presents an issue when it calls [MethodCaller.GetParameterTypes(parameters)] and [parameters] is null.


When [GetParameterTypes(null) is executed, it adds [result.Add(typeof(object));] to the result [type] list.


public static Type[] GetParameterTypes(object[] parameters)
{
List<Type> result = new List<Type>();

if (parameters == null)
{
result.Add(typeof(object));
}
else



I have a particular case where I define 2 public static methods on a class like this:


1. public static NewObject() {...}


2. public static NewObject(object obj} {...}



By default, when I try to Invoke the 1st. method with no parameters, CallFactoryMethod(..) with [null] as params[], it defaults to the 2nd. version of the method, due to its default parameter added by GetParameterTypes(..).


And it throws an exception because I'm not sending the [object] parameter, instead, I'm sending null as params.


I didn't get to check the implications of changing this behaviour on CSLA.


If anyone can suggest a simple workaround, it's welcome.


For now I'll use my own Reflection Functions to call on this factory methods for NewObject on my BOs.


Thanks to all,


Troncho


Wednesday, August 27, 2014  |  From VS Templates

We're looking at continuous integration tools for our in-house .NET and ASP.NET applications. In addition to the code, we also would like to update both schema and configuration data in our SQL Server database. Curious to know what others from this community have chosen and how they like their choice.


At this point, we're looking at CruiseControl.Net, Jenkins, TeamCity, and a strictly TFS solution using the Release Management functionality (which seems very expensive).


Thanks for your input.

Monday, August 25, 2014  |  From VS Templates

Hello,


I am reading the CSLA ebook and in the DataAccess ebook (page 114) are mentioned objects as SkillEditList, SkillEdit and library Library.Net and solution EncapsulatedInvoke, EncapsulatedInvokeDto ...


Or DataAccess.Mock, DataAccess.SqlCe, and DataAccess.SqlEf projects


Please could you advise, where can I download mentioned code sample.


In the samples dir of CSLA 4.1 version I am not able to find it.


Thank you

Saturday, August 23, 2014  |  From VS Templates

Wouldn't be better if the Value property in FieldData only set the IsDirty flag to 'true' when the new value was different  from the old value?


Cause the class uses generics, I've made the change as below:


        public virtual T Value


        {


            get


            {


                return _data;


            }


            set


            {


                if (_data == null && value == null)


                    return;


                if ((_data != null && !_data.Equals(value)) || 


                    (value != null && !value.Equals(_data)))


                {


                    _data = value;


                    _isDirty = true;


                }


            }


        }

Friday, August 22, 2014  |  From VS Templates

Please, correct me if I'm wrong, but FieldDataManager.UpdateChildren shouldn't be like this:


        public void UpdateChildren(params object[] parameters)


        {


            if (_propertyList == null) return;


            foreach (var pi in _propertyList)


            {


                if ((pi.RelationshipType & RelationshipTypes.Child) > 0)


                {


                    var item = _fieldData[pi.Index];


                    if (item != null)


                    {


                        object obj = item.Value;


                        if (obj is IEditableBusinessObject || obj is IEditableCollection)


                            Csla.DataPortal.UpdateChild(obj, parameters);


                    }


                }


            }


        }


The way it is now, all objects referenced by the businessobject are being treated as children even when they aren't.

Wednesday, August 20, 2014  |  From VS Templates

I am in the process of setting up Automated Tests using MSTest.  I would like to create a Mock DAL for the Test project.  The WPF app loads the DAL based on the appSettings tags in the App.Config file (CslaDataPortalProxy, ObjectFactoryAssembly, CslaObjectFactoryLoader).


The MSTest project does not have an app.config file so how I can point that project to the Mock DAL?


 


Using CSLA 4.5.501 and Visual Studio 2013.

Tuesday, August 19, 2014  |  From VS Templates

Hi,


This morning I was upgrading CSLA 4.3 to 4.5 and when I ran our application, anything using a ReadOnlyList failed in the DataPortal_Fetch.  I finally found the answer in this thread: http://forums.lhotka.net/forums/p/12449/56992.aspx


OK, easy fix alright.  Except than I ran into some slightly different fetch code.  My boss had been working on making a data loader use threads to speed up the process.  But on occasion, it would fail because a thread could be trying to read a list while one was writing to it (can't remember the exact details, as I wasn't directly working on this).  So we have a number of lists where the DataPortal_Fetch does this:


while (dataReader.Read())
{
    currentObject = Word.GetWord(dataReader);
    lock (loadingLock)
    {
        this.Add(currentObject);
    }
}

I'm trying to figure out whether I should put the "this.ReadOnly = false" and "... = true" code inside the lock, outside the lock but inside the while, or before/after the while.


Or is the above a big no-no to begin with?


Thanks,
Michel 

Monday, August 18, 2014  |  From VS Templates

Can anyone save some of my hair? :)


I'm trying to create an asp.net WEB API interface for an older CSLA project.  I am testing by hard coding the login on every request in various ways (once in the startup code, as an authorization request filter, inside the individual route request etc etc).  All the ways I tried work exactly once perfectly and then I get the infamous:


'Default principal object cannot be set twice.'


exception in BusinessPrincipal.vb (yeah I know it's very old, but it's released software, I can't upgrade CSLA)


I know that there is an issue where you need to set HttpContext.Current.User = Thread.CurrentPrincipal; due to some internal workings of the web API and I do that already, that has not resolved the issue.


I'd like to know if anyone has implemented a web api front end and how they handled this issue or any pointers as to what could be the solution.

 VS Templates News Feed 

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

Comments

No comments yet.