How to use U2.Data.Client for .NET Core Web API?

937 Views Asked by At

I am looking to create a connection with Universe DB using .NET Core Web API and run SELECT queries but I am getting an error and have heard that U2.Data.Client cannot be used for .NET Core. Is there any workaround for this?

Below is the code which I am trying to execute but an exception is thrown while initializing U2Connection:

U2Connection con = new U2Connection();
U2ConnectionStringBuilder csb = new U2ConnectionStringBuilder();
csb.AccessMode = "Native";
csb.RpcServiceType = "uvcs";
csb.Database = "HS.SALES";
csb.UserID = "user";
csb.Password = "password";
csb.Server = "localhost";
csb.ServerType = "universe";
con.ConnectionString = csb.ToString();
con.Open();

These are the exceptions which I get when calling the U2Connection constructor: System.TypeInitializationException: 'The type initializer for 'U2.Data.Client.U2Connection' threw an exception.'

MissingMethodException: Method not found: 'System.Security.Policy.Evidence System.Reflection.Assembly.get_Evidence()'.

1

There are 1 best solutions below

0
On BEST ANSWER

There is no .Net core version of Universe database connector yet! If you are using .Net core 2.x you can target .Net Framework as workaround to be able to use a .Net Framework library where you manage you Universe database access by using the available connector from U2 Toolkit for .NET. Hope this will help you.