Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> .NET Standard pre-processor switch and ConfigFileHelper
 

Pages: 1
LLBLGen Pro Runtime Framework
.NET Standard pre-processor switch and ConfigFileHelper
Page:1/1 

  Print all messages in this thread  
Poster Message
timothyleerussell
User



Location:

Joined on:
02-Oct-2008 07:48:55
Posted:
25 posts
# Posted on: 27-Aug-2019 02:19:21.  
Using 5.6, decided to start a project on Net Core...with the adapter templates.

I think there are two things that I don't understand.

1. The pre-processor directive in DataAccessAdapter for NETSTANDARD2_0 doesn't seem to be working for me (on VS2017 or VS2019). The project that I generated is set to .NET Core 2.0 but is choosing to compile the ConfigFileHelper line, which fails because ReadConnectionStringFromConfig does not exist in the .NET Standard 2.0 ORMSupportClasses. The ConfigFileHelper class exists but is empty (which I assume is fine because if the directive were working for me it would not be using the ConfigFileHelper class anyway.)

I solved this by removing this code and only leaving the RuntimeConfiguration line and then hooked it up in the Startup.cs of the project that consumes the data project.

Code:
private static string ReadConnectionStringFromConfig()
{
//#if NETSTANDARD2_0
            return RuntimeConfiguration.GetConnectionString(ConnectionStringKeyName);
//#else
//         return ConfigFileHelper.ReadConnectionStringFromConfig(ConnectionStringKeyName);
//#endif
}


And in Startup.cs

Code:
RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)", "connection string");

// Configure the DQE
RuntimeConfiguration.ConfigureDQE<SQLServerDQEConfiguration>(
c => c.SetTraceLevel(TraceLevel.Verbose)
.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
.SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));


This all works fine but of course when I regen the code, I have to go back in and modify the ReadConnectionStringFromConfig method.

Curious if there are other steps, such as a VS setting, to get the pre-processor directive to work?

2. I assume that I can have the consuming project set to a higher version of .NET Core (2.2 in this case) than the LLBLGen project (which is set to 2.0). I'm assuming so since it compiles and works fine with the changes I made above.

Thanks!
Timothy
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8088 posts
# Posted on: 27-Aug-2019 09:11:35.  
Hi Timothy,

In your generated project files (csproj) you have to set the target framework as .NET Standard 2.0 not netcore. (this should be the default when the files are generated) and the projects are then usable by any other project that targets a platform that's compatible with netstandard2.0 (and .net core 2.2 is compatible with netstandard2.0)


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
timothyleerussell
User



Location:

Joined on:
02-Oct-2008 07:48:55
Posted:
25 posts
# Posted on: 27-Aug-2019 19:27:39.  
Ok, thanks a lot.

I regenerated the project as .NET Standard 2.0 using VS 2019 and it worked fine, i.e. the pre-processor switch works now.

Appreciate you pointing me in the right direction.

I understood that .NET Standard is essentially a set of functionality covered in a specific .Net framework implementation but it didn't sink in that it was also a project target.

https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.