Compile error with 2 newest versions

Receiving the following error with the last 2 versions (2545 and 2549),
(E152) No accessible constructors for type TEntity

     method Backup<TEntity>(Source: TEntity); where TEntity is class;
         BackupData := new TEntity; <-- is the error line
         InternalBackup(Source, BackupData);

This compiles with 2543 (& previous versions) and executes properly.
I am using Visual Studio Community 2019 (Version 16.7.2).

Can I see a complete (non)compiling test case? Its touch to say what’s wrong since I don’t know what TEntity is and how its defined.

So there was a bug in the compiler. Above requires where TEntity is class, TEntity has constructor;

It always did but wasn’t properly enforced

1 Like

I did change the code to add , TEntity has constructor. The code then compiled. I also tried without the , TEntity has constructor and used Activator.CreateInstance. That compiled clean as well. I am using the original new TEntity with the with clause.

Thank you for the assistance.

1 Like