System.ComponentModel.InvalidEnumArgumentException when using TypedViewBase on .NET 7

Posts   
 
    
acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 01-Jun-2023 15:12:07   

Hi,

I'm using LLBLGen Pro Runtime Framework Version 5.9.2.

During the migration of a project to .NET 7 I noticed a problem with the constructor of SD.LLBLGen.Pro.ORMSupportClasses.TypedViewBase.

It looks as follows (decompiled):

        protected TypedViewBase()
        {
            base.RemotingFormat = SerializationFormat.Binary;
        }

The .NET 7 runtime seems to have an issue with the SerializationFormat.Binary enum value since it throws an exception on this line:

.ComponentModel.InvalidEnumArgumentException
  HResult=0x80070057
  Message=The SerializationFormat enumeration value, Binary, is invalid.
  Source=System.Data.Common
  StackTrace:
   at System.Data.DataTable.set_RemotingFormat(SerializationFormat value)
   at SD.LLBLGen.Pro.ORMSupportClasses.TypedViewBase`1..ctor(String tableName)
   at Project.Library.TypedViewClasses.RS_SomeSPResultTypedView..ctor() 
   at ConsoleApp1.Program.Main(String[] args)

There seems to be a workround for now: https://learn.microsoft.com/en-us/dotnet/core/compatibility/serialization/7.0/serializationformat-binary.

Still, how do you plan to addressed this? Or is this addressed in v5.10 already?

Best,

andreas

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 02-Jun-2023 09:37:38   

It's a known issue, tho for backwards compatibility reasons this is a bit more difficult to fix. We recommend using POCO based typedlists with linq or queryspec for .NET core/6+ for this reason; the legacy typedlist/views are based on datatables which are (much) slower to fetch as well. (https://www.llblgen.com/Documentation/5.10/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Adapter/Using%20TypedViews,%20TypedLists%20and%20Dynamic%20Lists/gencode_usingtypedlist_adapter.htm#choosing-the-typed-list-class-type)

Is this something you can work with or is this out of the question in your project? If it's not possible to migrate to these newer typedlist/view forms (they're the default for quite some time) we have to change the remoting format only for .net framework builds and drop it for netstandard builds. (I don't think it's a big issue but we'll see).

Frans Bouma | Lead developer LLBLGen Pro
acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 02-Jun-2023 09:46:14   

Hi Otis,

I guess that changing to a newer approach would be possible. I just have 2-3 places where TypedViews are used. In all those instances, its used to fetch the result set of a stored procedure call.

The code looks as follows:

var rs = RS_SpCallResultTypedView();
var query = RetrievalProcedures.GetQueryForRS_SpCallResultTypedView(param1, param2, adapter);
adapter.FetchTypedView(rs,  query);

What would be the approach to follow in order to achieve something similar but without using the typed view?

Thanks,

andreas

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 02-Jun-2023 10:03:59   

For a typed view mapped onto a stored procedure resultset, you have to queryspec as linq isn't supported in that scenario, see https://www.llblgen.com/Documentation/5.10/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Adapter/Using%20TypedViews,%20TypedLists%20and%20Dynamic%20Lists/gencode_usingtypedview_adapter.htm#outputtype-pocowithqueryspecquery-1 for an example.

So in your case (after you've switched the output type to PocoWithQuerySpecQuery), this will become

var rs = RetrievalProcedures.FetchRS_SpCallResultTypedView(adapter, 
      new QueryFactory().GetRS_SpCallResultTypedViewProjection(), param1, param2);

rs will be a List<T> where T is the poco type for the typedview

Frans Bouma | Lead developer LLBLGen Pro
acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 02-Jun-2023 10:19:42   

Ok thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 05-Jun-2023 11:18:13   

We've decided to remove the line from the netstandard build which sets the binary format. It's of no use in netstandard builds today anyway, as the supported .net frameworks derived from netcore are .net6+ and only .net6 supports a (minimal) binary serialization API which always has been incomplete. This is shipping in v5.10.1 which will release today.

I hope you haven't spent a lot of time rewriting the typedlists flushed Although moving to the new queryspec API is better anyway as fetching is much faster than with the legacy datatable based typedlists/views

Frans Bouma | Lead developer LLBLGen Pro
acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 05-Jun-2023 11:59:22   

Great, thanks.

I haven't worked on it yet. simple_smile