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

Error with Dynamanic List and Sorting Lists

0
0

Hello,

I am experiencing a problem with CSLA that didn't seem to be in the forums, until last week when someone else was experiencing the same problems as me. the post the question is in is marked with a suggested answer so this might be the reason why you have not seen it. however I am reposting it here in hope for a answer.

---------------------------------------------------------------------------------------------------------------------------------------------------------

 Original Post from  Cymro in forum post Error when pressing escape key on a filtered list bound datagridview

---------------------------------------------------------------------------------------------------------------------------------------------------------

I have tested this further and it appears that there are other issues around the CancelNew behaviour with a DataGridView.  The reason I was looking at this was because we are attempting to use a SortedBindingList and FilteredBindingList with a DynamicBindingListBase derived class.  The issue here is that when the list is Sorted (or filtered) the cancel new fails and leaves the invalid new item in the list.

I have tracked this down and found the issue but not a satisfactory resolution Tongue Tied

When a new row is added to a DataGridView the AddNew adds the object to the end of the list.  Even if the sorted is list is sorted it still goes at the end of the sorted list (which is what we want).

The issue is with the way that the DataGridView's DataBinding handles the cancelling. 

  1. The DataGridView calls CancelEdit on the child object through (IEditableObject.CancelEdit). 
  2. The changes get rolled back in the child object, but this has the side effect of raising OnUnknownPropertyChanged.
  3. PropertyChanged is handled by the parent BindingList and raises the IBindingList.ListChanged event with a ListChangeType of "Reset". 
  4. The SortedBindingList handles the ListChanged of the source list and calls DoSort, resorting all the items in the list (including the new item).  This is where the problem lies!!!
  5. The DataGridView then calls ICancelAddNew.CancelNew passing the last row index - but this is no longer where our item is, because it has been re-sorted into the middle of the list somewhere.

We do not see the effect of this issue in a BusinessBindingListBase because as part of the CancelEdit on the child, it calls to the parent list to remove it (when the EditLevel < EditLevelAdded) using IParent.RemoveChild(T child).  With a BusinessBindingListBase the implementation of this method removes the child, whereas with a DynamicBindingList does not.  Therefore, with a BusinessBindingListBase the new child is removed from the list before the CancelNew is even called (as part of step 2 above) which masks the issue with the CancelNew implementation of the SortedBindingList.

I am unhappy with this "fix" for two reasons. Firstly, the original comment in the method...

...suggests that this was thought about and decided this should not be done here.  And secondly because this just masks the real issue of the list getting re-sorted during the whole cancel process.

Now the obvious "fix" is to have the DynamicBindingList remove the child as part of the IParent.RemoveChild implementation as follows...

///<summary>/// This method is called by a child object when it/// wants to be removed from the collection.///</summary>///<param name="child">The child object to remove.</param>void Core.IEditableCollection.RemoveChild(Csla.Core.IEditableBusinessObject child)
    {
      Remove((C)child);
    }

I am unhappy with this "fix" for two reasons. Firstly, the original comment in the method...

      // do nothing, removal of a child is handled by
      // the RemoveItem override

...suggests that this was thought about and decided this should not be done here. And secondly because this just masks the real issue of the list getting re-sorted during the whole cancel process.  Does anyone have any thoughts?

---------------------------------------------------------------------------------------------------------------------------------------------------------

EDIT:

---------------------------------------------------------------------------------------------------------------------------------------------------------

Forgot to mention that I am using CSLA 4.0.1 and have also tried this on 4.2.something


Windows Identity Foundation - IClaimsPrincipal and IClaimsIdentity

0
0

Csla has a CslaPrincipal and CslaIdentity, fact. They can be overriden and customed and finally the ApplicationContext.User is set with an object implementing IPrincipal.

But what if the Wcf Service has to be an "Relying Party" as part of an WIF solution?

I have the requirement to set up Federated Authentication using IClaimsPrincipal and IClaimsIdentity. So far so good, but i don't want to put any knowledge to decrypt the Issued Token (a GenericXmlSecurityToken) to a ClaimsPrincipal.

If the client application doesn't has this knowledge then i think csla authentication fails, please correct me if i'm wrong. The authorization checks are done in the 'smart objects' client side and server side. IsInRole etc can't execute without knowing the ClaimsPrincipal. It should be possible, somehow, that the client only has an Issued Token and use that to call the custom WcfPortal with a WS2007FederationBinding

I'm thinking to go around this issue by creating a webservice to convert the Issued Token to a IClaimsPrincipal so that the knowledge to decrypt is on the server side, but this might be a security issue!

What is the best way to set SQL Server Context_Info using CSLA and EF5?

0
0

Hi all,

We need to log changes to the data using triggers in SQL Server 2012. The problem is that we need the id of the user that is currently accessing the database. We can set and later retrieve that id using SET CONTEXT_INFO (http://msdn.microsoft.com/en-us/library/ms187768.aspx) but that should be done when the connection is opened and with Csla managing connections, I don't know where to start.

Is there a way of doing this without modifying Csla code? I'm afraid that I'm not very familiar with the way the Csla DbContextManager works.

I'm using Csla 4.5.3 and Entity Framework 5.

Thanks in advance for your help.

Polymorphic Lists in Csla 4.0.1

0
0

Hi,

I have followed the guidelines suggested by Rocky for implementing a polymorphic Csla List.

http://www.lhotka.net/Article.aspx?id=b8515cd9-7f8e-43df-9efd-cd958dfdc21a

 

What is not described in above article is how to implement adding different types to the list.

Factory methods of list child objects should be internal, so I am assuming that one needs to expose public methods for adding on the list itself.

MyList.AddConcreteType1(ConcreteType1 params)

MyList.AddConcreteType2(ConcreteType2 params)

 

Am I missing something,? Is there a cleaner and slicker way to do this?

Thanks!

 

 

Multiple fetches at same time are not async

0
0

I have come across a problem I am trying to load up multiple business objects to display in the UI.  The first call is performed on a background thread but the other calls are on the UI thread.  Once this occurs all subsequent calls are on the UI thread.  e.g. to keep this simple I am fetching the same BO twice but in reality they are difference BO's.

            Settings.BeginGetSettings((o, e) => { });

            System.Threading.Thread.Sleep(1000);

            Settings.BeginGetSettings((o, e) => { });

 

    [Serializable]

    public class Settings : BusinessBase<Settings>

    {

        public static readonly Csla.PropertyInfo<string> WebServiceUrlProperty = RegisterProperty<string>(c => c.WebServiceUrl);

 

        public string WebServiceUrl

        {

            get { return ReadProperty(WebServiceUrlProperty); }

            set { SetProperty(WebServiceUrlProperty, value); }

        }

 

        public static void BeginGetSettings(EventHandler<Csla.DataPortalResult<Settings>> callback)

        {

            Csla.DataPortal.BeginFetch<Settings>(callback);

        }

        private void DataPortal_Fetch()

        {

            System.Threading.Thread.Sleep(5000);

        }

    }

If you put a breakpoint in DataPortal_Fetch() you will see the first time it is on a background thread and the second time it is on the main/UI thread.

This issue is caused by setting ApplicationContext.LogicalExecutionLocation to Server in Csla.Server.DataPortal.  The second call now reads it as Server in Csla.DataPortalClient.LocalProxy resulting in a synchronous call.  To make things worst the second call records _oldLocation as Server in Csla.Server.DataPortal since the first call has changed it.  Therefore when the second call completes it sets ApplicationContext.LogicalExecutionLocation to Server and now all calls will be synchronous.

I do not know the ins and outs of LocalProxy, DataPortal and how ApplicationContext.LogicalExecutionLocation is meant to work and hence I am cautious of making changes.  I suspect Server is important when using remoting which I am not.  I can also see that Server is used if a BO makes a call to another BO in the DataPortal_XYZ methods then it would be synchronous which is a good thing.

Any ideas on how to fix this issue?

Error when pressing escape key on a filtered list bound datagridview

0
0

In my Windows Form Application i have a datagridview bound to an Editable Child List representing a list of tariffs. I have some custom filters implemented through comboboxes and based on the values i select i build a filtered list for the tariffs.

        Dim mFiltered As New Csla.FilteredBindingList(Of ApTariff)(oApmailItemCharacteristic.ApTariffs)

        mFiltered.FilterProvider = AddressOf FilterTariff
        mFiltered.ApplyFilter("", oCriteria)
        Dim mSortedTariff As New SortedBindingList(Of ApTariff)(mFiltered)
        mSortedTariff.ApplySort("WeightFrom", ListSortDirection.Ascending)
        ApTariffsBindingSource.DataSource = mSortedTariff

The save for the object graph is working ok when editing existing rows on the tariffs grid, but when i try to add new rows i got an error of type "Edit Level Mismatch"

Also if the datagridview is empty because of the selection from comboboxes  and i try to add a new row and press the escape key i got the following error:

System.ArgumentOutOfRangeException was unhandled
  Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  Source=mscorlib
  ParamName=index
  StackTrace:
       at System.ThrowHelper.ThrowArgumentOutOfRangeException()
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at Csla.FilteredBindingList`1.OriginalIndex(Int32 filteredIndex)
       at Csla.FilteredBindingList`1.System.ComponentModel.ICancelAddNew.CancelNew(Int32 itemIndex)
       at Csla.SortedBindingList`1.System.ComponentModel.ICancelAddNew.CancelNew(Int32 itemIndex)
       at System.Windows.Forms.BindingSource.System.ComponentModel.ICancelAddNew.CancelNew(Int32 position)
       at System.Windows.Forms.CurrencyManager.CancelCurrentEdit()
       at System.Windows.Forms.DataGridView.DataGridViewDataConnection.CancelRowEdit(Boolean restoreRow, Boolean addNewFinished)
       at System.Windows.Forms.DataGridView.CancelEditPrivate()
       at System.Windows.Forms.DataGridView.CancelEdit(Boolean endEdit)
       at System.Windows.Forms.DataGridView.ProcessEscapeKey(Keys keyData)
       at System.Windows.Forms.DataGridView.ProcessDataGridViewKey(KeyEventArgs e)
       at System.Windows.Forms.DataGridView.OnKeyDown(KeyEventArgs e)
       at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
       at System.Windows.Forms.DataGridView.ProcessKeyEventArgs(Message& m)
       at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.DataGridView.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at MHS.Desktop.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

 

 

 

 

Rocky - it seems that cslastore@lhotka.net is not functioning

Silverlight Windows Authentification

0
0

Hi folks,

My organization would like to rely on Windows authentication to secure ours 3 tiers Silverlight applications, in order to provide some level of single sign-on functionality across all workstations.

In my case, the Silverlight hosting server is part of a Windows Active Directory domain and all users credentials and roles are managed as part of that domain. Some ours workstations are not part of the AD but workstations login access use an user account based on the AD credentials.

So, is it possible to authenticate the users against the windows domain (even is the workstation is not part of the domain) with 3 tiers Silverlight application?

In the very good csla ebook (Using CSLA 4: Data Portal Configuration), Rocky explains how to use Windows Authentification with silverlight application. But, I have also read some people use the ActiveDirectoryMembershipProvider for their AD authentication.

I'm wondering, what is the difference between Windows Authentification method use in the csla ebook and ActiveDirectoryMembership ? I would like also yours opinions/advises about what's techniques should be used ?

 

Thanks in advance for your help,

Best regards,

Cédric


What a proper way to implement strong authentication security?

0
0

Let's imagine next situation:
I'm a manager in big organization. That organization uses WinForms application (3 tier) written with CSLA framework. I have some skills in programming.
At one day, I open exe/dll of that application in tools like "ILSpy" or "Reflector" and export it to "csproj". I'm opening that "csproj" in Visual Studio and rewrite "Login" method:
this:

      public static void Login(string username, string password)
      {
           var identity = Library.CustomIdentity.GetCustomIdentity(username, password);
           Csla.ApplicationContext.User = new CustomPrincipal(identity);
      }

I change like this:

     public static void Login(string username, string password)
      {
           var identity = Library.CustomIdentity.GetCustomIdentity("admin");
           Csla.ApplicationContext.User = new CustomPrincipal(identity);
      }

I compile it back and load my modified application. In authentication window I enter any name, any password and voila - I'm working with "admin" rights.
Is it true?

Error: TCP error code 10048: Only one usage of each socket address

0
0

Hi,

We've been getting this error for the past few days - ever since we deployed a test version for the users, actually: TCP error code 10048: Only one usage of each socket address (protocol/network address/port) is normally permitted

This does not seem to happen on our development machines for some reason.  I've looked at various threads on StackOverflow and MSDN, but haven't found anything there that could possibly help since here it is really CSLA that's taking care of all the plumbing.

Anyone has an idea as to what we can check - be it on the client or server side - to resolve this?  The Net.TCP service is deployed as a Windows Service (the server is Windows Server 2003).

Thanks,
Michel

Validation with Priority help

0
0

I have a rule written as such:

BusinessRules.AddRule(Of BusObj)(_statusProperty, Function(obj As BusObj) obj.Status = "some test value", "Error Message", RuleSeverity.Error)

I am not having success adding the "With { .Priority = 1 }" to this.  Where does this go?  I can use this with other definitions, but can't find any references for the above version.

 

Thanks

OnPropertyChanged and maintaining a list of Dirty Properties

0
0

In CSLA 3.8 I was maintaining a list of dirty properties by overriding the OnPropertyChanged event and adding the propertyname to an internal list of strings if it didn't already exist. Then I would clear that list in an override of MarkOld.  This worked without any issue in 3.8.

But now in 4.3 the OnPropertyChanged event seems to be working differently with the new Rules system.  In 3.8 I would change a property, and I would get a single OnPropertyChanged event thrown for that property.  But in 4.2 it is also throwing the OnPropertyChanged for each dependent property of the property I changed. As a result, my dirty properties list contains a bunch of properties in it that aren't actually dirty because they were never changed.

Further, there are 2 OnPropertyChanged methods, one with a string parameter and one with a propertyinfo parameter. I've tried both of them and while the string parameter method would be thrown for the changed property and all it's dependent properties, the propertyinfo parameter method wasn't being thrown at all.

So my question is, what should I now be doing to keep track of a dirty properties list in 4.3? Should I be using another method altogether?

Here is my code in my base class right now that is being thrown for the changed property and its dependencies:

    Public Shared ReadOnly DirtyPropertiesProperty As PropertyInfo(Of Collection(Of String)) = RegisterProperty(Of Collection(Of String))(Function(obj As MyBusinessBase(Of T)) obj.DirtyProperties, "Dirty Properties"New Collection(Of String))    ''' <summary>    ''' A collection of the properties that have been changed    ''' </summary>    Public Property DirtyProperties() As Collection(Of String)        Get            Return GetProperty(DirtyPropertiesProperty)        End Get        Set(ByVal value As Collection(Of String))            SetProperty(DirtyPropertiesProperty, value)        End Set    End Property

    Protected Overrides Sub OnPropertyChanged(ByVal propertyName As String)        MyBase.OnPropertyChanged(propertyName)        ' Add the property to the list of dirty properties        If Not ReadProperty(DirtyPropertiesProperty).Contains(propertyName) Then            ReadProperty(DirtyPropertiesProperty).Add(propertyName)        End If    End Sub
    Protected Overrides Sub MarkOld()        MyBase.MarkOld()        ' clear all dirty properties        ReadProperty(DirtyPropertiesProperty).Clear()    End Sub

Any help would be greatly appreciated.
Thanks,
Mike

RemotingPortal fails when CSLA is moved from bin to GAC

0
0

I have a RemotingPortal configured and it works as it should. I have the following reference in the web,config:

<add assembly="Csla, Version=2.0.0.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30" />

I believe we are still on the older version because there are so many different solutions in place that utilize CSLA and we have not had an opportunity to evaluate the impact of changing versions across the board.

As noted above the RemotingPortal works but we have recently had an issue occur that requires us to move out assemblies out of the web application's bin folder and into the GAC. When CSLA is moved to the GAC the RemotingPortal no longer works. As soon as I move CSLA back to the bin it works again. Below is the error that occurs when CSLA is moved to the GAC. Is there a setting I am missing somewhere that will tell the RemotingPortal that CSLA is now in the GAC?

This is the output when I navigate to

https://www.site.com/RemotingPortal.rem?wsdl

System.IO.FileNotFoundException: Could not load file or assembly 'Csla' or one of its dependencies. The system cannot find the file specified.
File name: 'Csla'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at System.Runtime.Remoting.RemotingConfigHandler.RemotingConfigInfo.LoadType(String typeName, String assemblyName)
   at System.Runtime.Remoting.RemotingConfigHandler.RemotingConfigInfo.GetServerTypeForUri(String URI)
   at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI)
   at System.Runtime.Remoting.Channels.Http.HttpRemotingHandler.CanServiceRequest(HttpContext context)
   at System.Runtime.Remoting.Channels.Http.HttpRemotingHandler.InternalProcessRequest(HttpContext context)

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable  c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = DOMAIN\user
LOG: DisplayName = Csla
 (Partial)
LOG: Appbase = file:///C:/inetpub/wwwroot/wss/VirtualDirectories/www.site.com443/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\wss\VirtualDirectories\www.site.com443\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\wss\VirtualDirectories\www.site.com443\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/f8305cdb/d34d5b87/Csla.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/f8305cdb/d34d5b87/Csla/Csla.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/wss/VirtualDirectories/www.site.com443/bin/Csla.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/wss/VirtualDirectories/www.site.com443/bin/Csla/Csla.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/wss/VirtualDirectories/www.site.com443/_app_bin/Csla.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/wss/VirtualDirectories/www.site.com443/_app_bin/Csla/Csla.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/f8305cdb/d34d5b87/Csla.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/f8305cdb/d34d5b87/Csla/Csla.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/wss/VirtualDirectories/www.site.com443/bin/Csla.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/wss/VirtualDirectories/www.site.com443/bin/Csla/Csla.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/wss/VirtualDirectories/www.site.com443/_app_bin/Csla.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/wss/VirtualDirectories/www.site.com443/_app_bin/Csla/Csla.EXE.

 

 

Getting the MVC sample to work with the latest download

0
0

I struggled for a little while to get the MVC sample to work.  I wanted to outline the changes I needed to make.

* changed all projects from .NET 4 => .NET 4.5

* removed the override for Save() in Customer, which just called base.Save() anyway - can't override b/c Save is not virtual in latest CSLA.

* removed csla dlls throughout the solution and readded them from the dependencies folder within the samples folder - added the Csla.Web.Mvc4 dll - before the reference was just an invalid csla.web.mvc

*Adjusted the assemblies element in web.config:

      <assemblies>
        <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="Csla.Web.Mvc4, Version=4.5.30.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30"/>
        <add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>

** Adjusted this element in the runtime element of web.config to the following

      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
      </dependentAssembly>

At this point I believe I am able to run the sample as expected.  Just wanted to post this in case it was help to anyone.

Debugging Dal

0
0

How to debug Dal, DalEf projects?


"Class not registered" error when using EnterpriseServices transaction type.

0
0

I added a the Enterprise Services transaction attribute to a DataPortal_Fetch of a BusinessListBase object.

If called internally, it fetches fine, and will rollback when an exception occurs, but when called through a web service I get "DataPortal.Fetch failed (Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))"

In Expert CSharp 2008 Business Objects on page 519, we find:

"if you configure the data portal to run locally in the client process ... requires reference to System.EnterpriseServices.dll. It also has the side effect of requiring that Csla.dll be registered with COM+".  

As far as I know I have not configured the data portal to run locally (the only [RunLocal] I use is on methods that do not call the DataPoral), but since my error is related to registration I tried following these steps.

After adding the reference to EnterpriseServices, and registering Csla.dll with regsvcs.exe, I get the following error:

"DataPortal.Fetch failed (The ServicedComponent being invoked is not correctly configured (Use regsvcs to re-register).)"

I have tried re-registering, and also tried using regasm.exe, but to no effect.

It definitely is registered because I can see CSLA in Component Services under COM+ Applications. 

As a side note, DTC is enabled, and all firewalls are turned off.

I'm using visual Studio 2012, hosted on IIS 6.8. Operating system is Windows 8 64 bit. Build platform is set to AnyCPU.

Any help is appreciated. Thank you in advance. 

Can't build against 4.5.30?

0
0

I'm trying to incorporate Csla 4.5.30 into a project built on .Net 4.  I see that when I installed Csla under bin there's a NET folder and a NET4 folder; I assume NET contains Csla assemblies compiled against .Net 4.5, while NET4 contains Csla assemblies compiled against .Net 4.0.

When I build though I get the following errors:

1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "Csla.Web" could not be resolved because it has an indirect dependency on the framework assembly "System.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Csla.Web" or retarget your application to a framework version which contains "System.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "Csla.Web.Mvc3" could not be resolved because it has an indirect dependency on the framework assembly "System.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Csla.Web.Mvc3" or retarget your application to a framework version which contains "System.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>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.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Csla" or retarget your application to a framework version which contains "System.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

Any ideas?

 

AppDomain, UserPrincipal, Serialization Problems (SL5, .NET 4.5, IIS Express)

0
0

Howdy All,

I have a pretty neat problem and I'd appreciate any and all help...You see, I am having a bit of a hiccup with trying to create and run code in dynamically-created AppDomains.


Here is my situation and troubleshooting so far:


I create an AppDomain object in the standard way that I've read up on. I've gotten this to work away from my CSLA projects and it works fine. Here is the code as it is this second:


public class ServiceManager

{

...

  [System.Security.SecurityCritical]
  private IAutonomousServiceContext CreateContext()
{

      AppDomainContext retContext = null;

      try
      {

        AppDomainSetup ads = new AppDomainSetup();
        ads.ApplicationBase =
            System.Environment.CurrentDirectory;
        ads.DisallowBindingRedirects = false;
        ads.DisallowCodeDownload = true;
        ads.ConfigurationFile =
            AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

        var appDomainName = AutonomousResources.AppDomainNamePrefix +
                            DateTime.Now.ToLongTimeString() +
                            RandomPicker.Ton.PickLetters(Configuration.DefaultContextRandomSalt) +
                            AutonomousResources.AppDomainNameSuffix;
        AppDomain ad2 = AppDomain.CreateDomain(appDomainName, null, ads);
        //ad2.AssemblyResolve += ad2_AssemblyResolve;
        //ad2.Load("LearnLanguages.Business, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
        var contextType = typeof(AppDomainContext);
        var assembly = contextType.Assembly.FullName;
        retContext =
          (AppDomainContext)ad2.CreateInstanceAndUnwrap(assembly,
                                                        typeof(AppDomainContext).FullName);

        return retContext;
      }
      catch (Exception ex)
      {
          Services.PublishMessageEvent(ex.Message, MessagePriority.VeryHigh, MessageType.Error);
        throw;
      }

  }

...

}


The original exception I got was:


"Type is not resolved for member 'LearnLanguages.Business.Security.UserPrincipal,LearnLanguages.Business, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."}    System.Exception {System.Runtime.Serialization.SerializationException}

After reading Rocky's reply for another question, I came to believe the problem stemmed from the assembly not being loaded into the AppDomain. Then when it goes to try to serialize my principal object (because of passing thread information to the newly created AppDomain), it can't serialize the thing because it can't find it in any of its assemblies. This is still what I believe to be the case, but I still am having the hiccup - I can't figure out how to get around it (yet).

I tried Rocky's workaround given in that article, but no dice. The workaround focuses on the AppDomain's resolve event handler. So, I implemented the handler, hooked it up - I tried this on the newly created child AppDomain, as well as even the main application's AppDomain (and both at the same time); however, each permutation left me a similar error:

Type is not resolved for member 'LearnLanguages.Autonomous.Core.ServiceManager,LearnLanguages.Autonomous, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

This time, the error is not in my business assembly, but rather the calling assembly...the class it's balking on is the declaring class in the above code snippet is doing (trying to do) the creating of the child AppDomain! So it seems as soon as I try to do anything with the AppDomain object (which does indeed descend from MarshalByRefObject btw), it blows up on me.

I also tried to load assemblies explicitly, as shown in the commented line in the original code snippet, as well as follows...

//ad2.Load("LearnLanguages.Business, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");

 

...but this also throws the exception about the UserPrincipal serialization problem.

So as best I can tell, the problem is that the second app domain can't be touched without initiating the problem of the current thread's UserPrincipal object. Do you think this is the case? If so, is there some hack way around this, or is there something else that I am missing?

Like I said, this is a pretty nifty problem, and I'm sure there's going to be an equally nifty solution...I'm just not thinking of it yet! Or, perhaps any of you could give me any suggestions for this?

 

Local DataPortal works, but Remote DataPortal does not

0
0

On my local development machine, I have a WinForms app that connects to the WCF based DataPortal and everything works fine.

When I publish the DataPortal to the server and change my connection in my WinForm app to use the remote data portal, it throws the following exceptions:

"The caller was not authenicated by the service."

"The request for the security token could not be satisifed because authenication failed."

When I browse to http:://www.mycompany.com/DataPortal.svc, I get the proper information and can display the WSDL information, too.

My web.config has this in it:

     <system.serviceModel>
        <services>
            <service name="Csla.Server.Hosts.WcfPortal" behaviorConfiguration="returnFaults">
                <endpoint
                    contract="Csla.Server.Hosts.IWcfPortal"
                    binding="wsHttpBinding"
                    bindingConfiguration="wsHttpBinding_IWcfPortal"/>
            </service>
        </services>
        <bindings>
            <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"/>
                    <serviceMetadata httpGetEnabled="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>

 And my app.config contains the usual CSLA settings:

<add key="CslaPropertyChangedMode" value="Windows"/>
<add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla"/>
<add key="CslaDataPortalUrl" value="http://www.mycompany.com/DataPortal.svc"/>
<add key="CslaAuthentication" value="Csla"/>

 Any guidance for how I can use my data portal once it's published to the server?

 

 

IClientValidatable & MVC

0
0

I'm trying to convert some existing validation attributes to business rules.  I have some which implement IClientValidatable (most of our validation is actually on the view models, something I'm trying to fix by bringing in Csla).  I can easily build the rule in Csla, but my question is how to keep the client side validation.  Bringing the attribute into the business layer would not work as the IClientValidatable attribute is MVC only.

Any ideas on getting the validation client side as well? 

Viewing all 764 articles
Browse latest View live




Latest Images