MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

CSLA .NET version 4.7.100 release #510

Open rockfordlhotka opened 6 years ago

rockfordlhotka commented 6 years ago

I am pleased to announce the release of CSLA .NET version 4.7.100 with full support for netstandard 2.0 and .NET Core 2.

The packages are now in NuGet. Once some final updates to the samples are complete and merged into master I'll create a formal release tag/page on GitHub.

This release also includes some other very exciting capabilities, including:

There are a couple known issues with this release:

Regarding the NuGet/assembly split noted in #822:

Right now there are two "families" of CSLA .NET packages in NuGet. One that supports full .NET and one that supports all other runtimes.

The full .NET family must be used for the following types of app:

The netstandard family must be used for the following types of app:

What this means for you is that if your n-tier app is 100% full .NET or full netstandard then you can live within one of those families. BUT if your server is full .NET and your client is Xamarin (for example) then your business library assemblies need to be compiled twice: once for full .NET and once for netstandard.

The Samples\ProjectTracker app shows how this is done by using a Shared Project to contain the code, and two concrete class library projects that compile the code for full .NET and netstandard respectively.

brinawebb commented 6 years ago

Congratulations Rocky and Team! This is a truly amazing milestone that should go down in history. I've been using Csla since 1997 and am constantly amazed at how we can re-use our Library. Phones, cross platform, web, etc... Hats off to you all!

tfreitasleal commented 6 years ago

I updated a few projetcs to CSLA .NET 4.7.100 and found out that projects can't target plain 4.6 any longer. I got a ton of errors and the message

The primary reference "Csla, Version=4.7.100.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.6.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".

If your CSLA project targets 4.6, you must upgrade it to 4.6.1 (at least) or downgrade it to 4.5.x

Of course I suggest to upgrade because 4.6.1 implements NetStandard 2.

Upgrading the .NET target isn't as easy as it sounds, because of all the NuGet packages your project uses.

My suggestion is to remove all NuGets from the project, upgrade the target framework to 4.6.1 and restore all NuGet dependencies.

johntco commented 6 years ago

I upgraded to 4.7.100 of CSLA the other day and retargeted my libraries and apps to 4.7.1 runtime. I discovered that all I needed to do was open the NuGet Package manager and run this statement:

Update-Package -Reinstall

That actually upgraded my nuget packages to my new app runtime target.

tsf1 commented 6 years ago

I updated to this release (4.7.1) for a MVC site where we were having major connection leak issues (see issue #377) and we're still seeing the same problems after the update. I'm wondering if I have incorrectly coded my use of the ConnectionManager.

Here's our DalManager:

    public class DalManager : DataAccess.IDalManager
    {
        private static string _typeMask = typeof(DalManager).FullName.Replace("DalManager", @"{0}");

        public T GetProvider<T>() where T : class
        {
            var typeName = string.Format(_typeMask, typeof(T).Name.Substring(1));
            var type = Type.GetType(typeName);
            if (type != null)
                return Activator.CreateInstance(type) as T;
            else
                throw new NotImplementedException(typeName);
        }

        public ConnectionManager<SqlConnection> ConnectionManager { get; private set; }

        public DalManager()
        {
            ConnectionManager = ConnectionManager<SqlConnection>.GetManager("ConnectionString");
        }

        public void Dispose()
        {
            if (ConnectionManager != null)
            {
                ConnectionManager.Dispose();
                ConnectionManager = null;
            }
        }
    }

And here's the DalFactory:

    public static class DalFactory
    {
        private static Type _dalType;
        public static IDalManager GetManager()
        {
            bool reloadDal = false;

            if ((_dalType == null) || (reloadDal))
            {
                string dalTypeName = "Customer.DataAccess.Sql.DalManager,Customer.DataAccess.Sql";

                if (!string.IsNullOrEmpty(dalTypeName))
                    _dalType = Type.GetType(dalTypeName);
                else
                    throw new NullReferenceException("DalManagerType");
                if (_dalType == null)
                    throw new ArgumentException(string.Format("Type {0} could not be found", dalTypeName));
            }

            return (IDalManager)Activator.CreateInstance(_dalType);
        }
    }

Here's the typical flow for DP methods:

        private void DataPortal_Fetch(UserCriteria criteria)
        {
            using (var dalManager = DataAccess.DalFactory.GetManager())
            {
                var dal = dalManager.GetProvider<DataAccess.IAccountDal>();

                try
                {
                    using (var data = new Csla.Data.SafeDataReader(dal.GetAccount(criteria.AccountId)))
                    {
                        if (!data.IsClosed && data.Read())
                        {
                            UserName = data.GetString(data.GetOrdinal("Name"));
                            EmailAddress = data.GetString(data.GetOrdinal("EmailAddress"));
                        }
                        data.Close();
                    }
                }
                catch (Exception ex)
                {
                    // log exception info and throw;
                }

                // get the list of stores associated to this user account
                AssociatedStoreList = CustomerInfoList.GetAssociatedCustomers(criteria.AccountId);
            }            
        }

And finally, here's the typical DAL method when calling stored procs:

        public IDataReader GetAccount(int accountId)
        {
            using (var ctx = ConnectionManager<SqlConnection>.GetManager("ConnectionString"))
            {
                var cm = ctx.Connection.CreateCommand();
                cm.CommandType = CommandType.StoredProcedure;
                cm.Parameters.AddWithValue("@AccountId", accountId);
                cm.CommandText = "customer.getAccount";

                return cm.ExecuteReader();
            }
        }

Does anything look wrong with this? Am I missing something? Thanks for helping. Tim

rockfordlhotka commented 6 years ago

@tsf1 can you open a new issue with this info so it doesn't get buried in this thread about the 4.7.100 release?