Quantcast
Channel: CSLA .NET
Viewing all 764 articles
Browse latest View live

HttpContext.Current is null in server-side DataPortal methods?

$
0
0

Hi,

I'm gradually introducing CSLA into our existing application. It's a MVC / Silverlight app using WCF services hosted in IIS.

For each WCF call, the existing code creates and stores an EF DbContext in HttpContext that is then used for the duration of that call (the DbContext is created / destroyed in the HttpApplication's BeginRequest / EndRequest event handlers).

As I'm gradually adding CSLA business objects into the mix, I've come across an issue where the HttpContext.Current ends being null within the DataPortal XYZ methods. I need access to HttpContext so that my CSLA business objects (from their server-side DataPortal XYZ methods) can calls some of the pre-existing code that relies on HttpContext containing the EF DbContext used for managing database access.

Below is an example of the code I'm using:

        public async static Task<ReportQuery> ExecuteAsync(ReportCriteria criteria)
        {
             var cmd = new ReportQuery { ReportCriteria = criteria };
             cmd = await DataPortal.ExecuteAsync<ReportQuery>(cmd);
             return cmd;
        }

        protected async override void DataPortal_Execute()
        {
             // This is where System.Web.HttpContext.Current is NULL
        }

I added breakpoints to the HttpApplication's BeginRequest and EndRequest event handlers (that are wrapped around the call to my CSLA DataPortal XYZ methods), and was able to confirm that HttpContext.Current did contain a 'real' value. Unfortunately, this HttpContext does not make its way further down the chain to the CSLA DataPortal XYZ methods.

I've tried quite a few things,but no luck yet. I made sure to include the following in Web.config, to ensure that HttpContext is accessible within WCF:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

Any ideas?

Thanks,
Pete 


Upgrading CSLA

$
0
0

I am currently going through and attempting to upgrade an application with CSLA 3.6.3 and .net framework 3.5 to the .net framework 4.0 and csla 4.5. I am attempting to do this in a phased approach and trying to include both version of CSLA in the same solution.

I have gotten CSLA 3.6.3 renamed and changed all of its namespaces so that it will appear to co-exist with csla 4.5. But now I am getting an error that I just can't figure out.

When I add a new class that references the new csla and simply inherit from one of the csla base classes I get the following error.

"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information"

I have done a lot of research and found that if go into the assemlyInfo.vb file and comment out the following code I get a little better error.

[assembly: System.Security.AllowPartiallyTrustedCallers]

The new error is:

Description:
"There was an error reflecting type 'class name'.

File:
SGEN

I believe the problem is related to the Security transparency change that occurred between .net framework 3.5 and .net framework 4.5. Any suggestions on how to solve this issue would be greatly appreciated.

 

 

Question about RunLocal()

$
0
0

Can someone tell me if RunLocal has any effect on serialization through the DataPortal methods? Although everything we do is run locally, we have typically not marked everything with RunLocal. However, one of my classes is generating OutOfMemory exceptions and I'm pretty sure it's the result of serialization of slightly larger object graphs, 200-300 objects, no blobs. (And yes, I've confirmed that I don't have any recursive references.)

Custom Authentication

$
0
0

Hi..

Is there any example of CSLA application which uses Custom Authentication?

Instead of ASPNET membership authentication,I want to use Custom Authentication in a Silverlight project (developed using CSLA).

Please suggest..

 

 

Remove Methods on Editable Root Collection not getting fired

$
0
0

Hi

I have generated an Editable Root Collection through cslagenfork. In windows forms, binding source's Remove() or RemoveCurrent() method is called to delete the current object. But some how the remove methods of the root collection are not being fired. I have put some logic in the remove methods to check referential integrity.

        public new bool Remove(ColorEC item)        { 

            if (!CanDeleteObject())

                throw new System.Security.SecurityException("User not authorized to remove a ColorEC.");

            ColorRIExistsCommand cmd = new ColorRIExistsCommand(item.NKey);

            cmd = Csla.DataPortal.Execute<ColorRIExistsCommand>(cmd);

            if (cmd.ColorExists)

                throw new System.Exception("Related records exist. Can't delete record");

            return base.Remove(item);

        } 

Status and Recommendations on CLSA, MVVM and Universal Apps

$
0
0

Getting back into it all from some time away and trying to match all the proper bits together to get started.  Universal App templates seem like a good idea and I know CSLA is something I want.  MVVM makes a ton of sense.

Not really sure if there is a recommended MVVM toolkit or framework, though.  I see lots of activity on MVVM Light.

I haven't investigated fully, but it seems like there might be some overlapping functionality between CSLA and MVVM Light when it comes to properties and their changed events.

Primary target is WP8.1 and ASP.NET MVC.

Any guidance or recommendations?

Any giant bear traps I have to look out for?

TIA

Is anyone using Prism 4 and CSLA 4.x?

$
0
0

If so, anything in particular to watch out for?

Issue with NuGet package

$
0
0

I just had a bit of an issue with the Csla-Core NuGet package.  Basically because the dependency specifies Bcl.Async >= 1.0.165 if you install Csla today it will grab the latest, which also depends on a later Bcl version as well.  The issue is that Csla itself is built against System.Runtime 2.6.6, which caused an issue with FxCop as NuGet got 2.6.7 and FxCop will not let you use 2.6.7 in place of 2.6.6.  I'm not sure if this is because Csla is strong named too. 

Also, is there any reason to strong name Csla?  If there is can we have a -Unsigned package as well? 


Is ReadOnlyBase.ReadProperty intended to be thread safe?

$
0
0

Hi all

We just ran into a very nasty problem in production where a statically shared CSLA ReadOnlyBase object (used for caching static information to reduce DB hits) caused the Application Service hosting the WCF data portal to max out the CPU's at 100%.

After catching the issue happening again, doing a memory dump and some adventures in WinDbg + SOS,
tracked it down to all the threads sitting at the top of the following stack:

 

System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.Boolean, mscorlib]].FindEntry(System.__Canon)

Csla.ReadOnlyBase`1[[System.__Canon, mscorlib]].CanReadProperty(System.String)

Csla.ReadOnlyBase`1[[System.__Canon, mscorlib]].GetProperty[[System.Int32, mscorlib]](Csla.PropertyInfo`1<Int32>, Csla.Security.NoAccessBehavior)

 

The ReadProperty method actually seems to cope, but it's the lookup of the property in the Field Manager Dictionary where it goes pear shaped.

As a workaround, we're instead caching the individual valuetype values instead of the object and creating clones for reference types.

Just wanted to know what the expectation of multi-threaded access to a CSLA business object's properties are from a design point of view.

CSLA fiddler inspector?

$
0
0

Our company has a few third-party CSLA/Silverlight applications that we use internally.  I am on the information security team and would like to be able to examine the requests/responses that the silverlight application communicates, but the raw HTTP requests/responses are in their serialized form, which doesn't make for easy viewing.  As we don't have the source for these application, is there there a Fiddler inspector that could be used to view the deserialized traffic?  If not, could someone point me, in terms of the CSLA serialization, the direction I need to go in order to write an appropriate inspector?

Bug in Csla 4.5.501 - NRE if BusinessRule ctor blows up

$
0
0

I think I found a bug in Csla 4.5.501.

You can recreate it by creating a simple editable business object and a business rule where the rule ctor throws an exception. 

In my case, I was throwing an ArgumentException if one of the propertyInfo.Type != typeof(string) as the rule only works against string properties.

The end result was that Csla from the SimpleDataPortal was throwing a NullReferenceException which was not the exception actually thrown by the ctor prior to the call getting to my DP_F method..  I'm calling this a bug because it took me a few hours to figure out what was going on.  I would have expected to see my ArgumentException somewhere, not a NRE from an anonymous' classes MoveNext method. :-)

How do I debug?

$
0
0

How do I use debugger in DAL when working with CSLA + Silverlight Project?

Windows Phone 8.1

$
0
0

Whew.  I'm getting a nasty case of "rev-lock" here.  Every direction I turn the various tools I want to use seem to be out of sync with every other tool.  I think it's great that Microsoft is stepping up and iterating more quickly, I'm not sure if the rest of us can take the load.

I am locked into Windows Phone 8.1 because the project I'm starting requires Bluetooth LE support and that's only in Windows Phone 8.1.  The BTLE support on the other MS platforms is pretty good as far as I can tell.  But this is a mobile app and Windows Phones are the target.

So, I realize the no one's asking about WP specifically for CSLA, let alone WP8.1.  Is there a plan at this point to address it specifically? 

If I understand things correctly, the Universal App enhancement might solve this problem, but is there a timetable that can be shared for that?

Can anyone suggest an approach in the meantime that minimizes the lost time?

TIA - Bill

CSLA/Silverlight VB.Net "Presenter" code

$
0
0

Hi gents,

This is more a .Net C/VB question, but I'm trying to create a Silverlight project using VB.Net as opposed to the C# that is provided in examples..

Can anyone give me a pointer as to how THIS code is implemented as VB.Net?

       var presenter = (IPresenter)Bxf.Shell.Instance;
      presenter.OnShowError += (message, title) =>
        {
          Shell.Instance.ShowView(
            typeof(Views.ErrorDisplay).AssemblyQualifiedName,
            "errorViewSource",
            new ViewModels.Error { ErrorContent = message },
            "Error");
        };

      presenter.OnShowStatus += (status) =>
        {
          Shell.Instance.ShowView(
            typeof(Views.StatusDisplay).AssemblyQualifiedName,
            "statusViewSource",
            status,
            "Status");
        };

      presenter.OnShowView += (view, region) =>
        {
          switch (region)
          {
            case "Main":
              MainContent = view.ViewInstance;
              break;
            case "Menu":
              MenuContent = view.ViewInstance;
              break;
            case "User":
              UserContent = view.ViewInstance;
              break;
            case "Error":
              _errorClose = DateTime.Now.Add(new TimeSpan(0, 0, 5));
              ErrorContent = view.ViewInstance;
              break;
            case "Status":
              _statusClose = DateTime.Now.Add(new TimeSpan(0, 0, 5));
              if (view.Model != null)
                AppBusy = ((Bxf.Status)view.Model).IsBusy;
              else
                AppBusy = false;
              StatusContent = view.ViewInstance;
              break;
            default:
              break;
          }
        };

I've tried various conversion tools and the code they come up with is not valid.

I'm a VB guy and trying not to confuse matters even more by developing in a "foreign" language on top of having to learn Silverlight development, MVVM and upgrade to the latest CSLA...

Any help would be appreciated.

Thanks,

Graham

 edit: (as for whatever reason, it doesn't show my replies to my own post.. ugh).

Here's what have done for the OnShowView event in VB.Net, will this suffice?

    Public WithEvents presenter As IPresenter = DirectCast(Bxf.Shell.Instance, IPresenter)
    Private Sub presenter_OnShowView(ByVal view As Bxf.IView, ByVal region As String) Handles presenter.OnShowView

        Select Case region
            Case "Main"
                MainContent = view.ViewInstance
                Exit Select
            Case "Menu"
                MenuContent = view.ViewInstance
                Exit Select
            Case "User"
                UserContent = view.ViewInstance
                Exit Select
            Case "Error"
                _errorClose = DateTime.Now.Add(New TimeSpan(0, 0, 5))
                ErrorContent = view.ViewInstance
                Exit Select
            Case "Status"
                _statusClose = DateTime.Now.Add(New TimeSpan(0, 0, 5))
                If view.Model IsNot Nothing Then
                    AppBusy = DirectCast(view.Model, Bxf.Status).IsBusy
                Else
                    AppBusy = False
                End If
                StatusContent = view.ViewInstance
                Exit Select
            Case Else
                Exit Select
        End Select

    End Sub

System.NotSupportedException: Invalid for root objects - use Delete instead

$
0
0

Hi Friends,

I'm new to CSLA and I'm currently working on one of our project done using CSLA. I'm getting the following exception when trying to remove an item from the collection. I tried the Delete method but that is not affecting the collection. Can you please shed some light on how to address this issue?

System.NotSupportedException was caught

  Message=Invalid for root objects - use Delete instead

  Source=Csla

  StackTrace:

       at Csla.Core.BusinessBase.DeleteChild()

       at Csla.Core.BusinessBase.Csla.Core.IEditableBusinessObject.DeleteChild()

       at Csla.BusinessListBase`2.DeleteChild(C child)

       at Csla.BusinessListBase`2.RemoveItem(Int32 index)

       at System.Collections.ObjectModel.Collection`1.RemoveAt(Int32 index)

 

Thanks,

Hemant.


CSLA Behaviour with new unchanged entities

$
0
0

Hi,

I was writing some unit tests for code developed within the team and accidentally discovered that creating a new entity and calling save does not actually cause the new entity to be saved but instead returns a still new entity.

I was told that this is the expected behaviour of CSLA, that CSLA only saves an entity once it is dirty and not just because it is new. Is this correct?

Nick

MVC 4.5.40?

$
0
0

Howdy howdy,

First off, Rocky, I just read about your major event, and I just want to say I wish the best to you. I've learned a lot about n-tier architecture and good practices from you and I really appreciate all you've done and continue to do! And of course, that goes for the rest of the people working on CSLA as well!


Now, to my problemo...


I am trying to convert my web page to MVC5, and I'm seeing that all of the versions of CSLA are at 4.5.40 *except* MVC! This one is still at 4.5.10.

Any idea at when this will be updated?


I have tried just building from source (csla.web.mvc5 4.5.491), but it's still a no-go with the data portal (which was working in my webforms project). It's possible that I am forgetting to configure something properly, but I don't think so. Usually when I get to this point of the dataportal failing, it is because I do not have all the csla assembly versions match.


This is not my forte, so I appreciate any help y'all can give.


Thanks,

Bill Raiford

List of Roles

$
0
0

I have a table which contains list of Business objects with corresponding accesses for roles. Now I wish to retrieve list of roles authorized to access particular business object in AddObjectAuthorizationRules()

how do I write a method which retrieves Roles from database for Authorization for that particular object?

Where is "OrderShipper" ?

$
0
0

UsingCsla4-03-DataAccess.pdf refers to an OrderShipper class (page 151)  in Library.Net project in the EncapsulatedInvoke solution.

I have Csla versions going back to 4.0, but cannot seem to find the OrderShipper anywhere. I also cannot find the EncapsulatedInvoke.sln anywhere.   The only Library.Net project I have come across is in the PagedList.sln.  The Library.Net project in that has nothing called "OrderShipper".

I am looking for an example of DataPortal.BeginExecute.  I would appreciate some help.  Thanks.

Jav

Universal Apps

$
0
0

I know a number of people are interested in universal apps and how/if CSLA supports them.

First, I'm working on adding Windows Phone WinRT 8.1 support and that should be available in a couple weeks. We already support WinRT on Windows 8.1.

I've done some testing with universal apps, and with the broader concept of the shared code project tooling Microsoft added to support universal apps.

In terms of actual universal apps (WinRT on Win8.1 and WP8.1) that'll work exactly as expected once the WP8.1 support for CSLA is in nuget. You'll create your universal project (solution actually) and reference CSLA via nuget in both UI projects. Then you'll write your common code in the shared code project and everything will work just like it does with every other nuget package that supports both platforms.

(the only caveat is that WinRT on WP8.1 doesn't support WCF, so you'll need to use the new HttpProxy data portal channel I've created to overcome this limitation)

In terms of broader use of shared code projects, this is pretty cool (to say the least).

It turns out that what Microsoft has done with these shared code projects is to create a really easy way to link code files from one project into other projects. This is _exactly_ what we've all been doing with manual file linking over the past many years, but automated.

This works with any type of project.

As a result, you can use a shared code project and reference it from UI projects such as Windows Forms, WPF, WinRT, Android, iOS, etc.

What this means is that you can use the same file linking technique I've been talking about and using for all these years, but in a much simpler way - the result being that you can create one set of business class code and reuse that same code easily in numerous client projects, such as:

  • Windows Forms or WPF
  • WinRT for Windows 8
  • WinRT for Windows Phone
  • Android
  • iOS

I put Windows Forms/WPF in there in particular, because most people are currently using those technologies. If all you do is shift your business classes into a shared code project you can keep your app working as it is today - no actual code changes.

BUT when you want to create an Android or iOS client using Xamarin you'll be all ready to link in your existing class files as you build the new client apps.

And if you want to support WinRT the same thing is true - just reference the shared code project from your WinRT project(s) and you are all set.

Viewing all 764 articles
Browse latest View live