on 2022 Nov 23 9:03 AM
Dear Folks,
I am trying to connect SAP HANA instance from VS Code using .net 7.0.
I have installed .net7 SDK and SP
I am getting below error while creating HanaConnection object.
Exception has occurred: CLR/System.TypeInitializationException
An exception of type 'System.TypeInitializationException' occurred in Sap.Data.Hana.Core.v2.1.dll but was not handled in user code: 'The type initializer for 'Sap.Data.Hana.HanaConnection' threw an exception.'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception System.IO.FileNotFoundException : Cannot find a matching libadonetHDB.dll with version 2.11.14 - check the location in the HDBDOTNETCORE or PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH environment variables
(Process) HDBDOTNETCORE=C:\Program Files\sap\hdbclient\dotnetcore
(Machine) HDBDOTNETCORE=C:\Program Files\sap\hdbclient\dotnetcore
Searched paths and results:
C:\Program Files\sap\hdbclient\dotnetcore\libadonetHDB.dll : 2.14.22 : False
C:\Program Files\sap\hdbclient\dotnetcore\libadonetHDB.dll : 2.14.22 : False
C:\Program Files\SAP\hdbclient\ado.net\libadonetHDB.dll : 2.14.22 : False
at Sap.Data.Hana.HanaUnmanagedDll.SearchNativeDlls()
at Sap.Data.Hana.HanaUnmanagedDll..ctor()
at Sap.Data.Hana.HanaUnmanagedDll.get_Instance()
at Sap.Data.Hana.HanaConnection..cctor()
You may refer below code for reference.
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using TestCode.Models;
using Sap.Data.Hana;
namespace TestCode.Controllers;
public class HomeController : Controlle{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger){
_logger = logger;
HanaConnection conn = new HanaConnection();
conn.ConnectionString = "connectionstring";
conn.Open();conn.Close();
}
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
This is a simple HANA client version mismatch, but it's not your fault. It can be solved in different ways, see this for a detailed explanation - https://stackoverflow.com/questions/45233832/ado-net-provider-for-sap-hana-version-mismatch-issue
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
11 | |
10 | |
10 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.