-
Getting the below error from a .net core web api app. Do the net weaver dlls need to be configured in PATH ? |
Beta Was this translation helpful? Give feedback.
Replies: 28 comments 11 replies
-
Where should these DLLs be located in relation to the output directory ? |
Beta Was this translation helpful? Give feedback.
-
all dlls from nwrfcsdk lib folder should be copied to output directory of executables. |
Beta Was this translation helpful? Give feedback.
-
so a little more info. It looks like I'm running into an issue with .net core 2.1. Are there any known issues with core 2.1 ? |
Beta Was this translation helpful? Give feedback.
-
No I think I was wrong. core 2.1 and core 3.1 both give me that error saying those DLLs should be in PATH |
Beta Was this translation helpful? Give feedback.
-
Problems like this are typical related to the point that nwrfcsdk is platform specific (this also applies to x64/x86). While you are normally don't have to care on .NET if you are running a x64 or a x86 process you have to if you use a C++ dll like the sdk. therefore we typical use
in project sdk file.
|
Beta Was this translation helpful? Give feedback.
-
Good questions. I'm in Visual Studio 2019 using IIS Express. However, I will eventually need this to work in an IIS environment, and a kubernetes environment. The icu dlls are in the output directory. I downloaded the x64 version of nwrfcsdk. Is there any way I can confirm that ? Should I be using the x86 version? A little more info. Everything seemed to work in a core 3.1 console app when I went thru your blog step by step. What I'm trying to do now is get it to work in a core 2.1 web api application. EDIT: This was a mistake. Our apps are targeting core 3.1, not 2.1 |
Beta Was this translation helpful? Give feedback.
-
let me have a look, I will add some samples for these platforms (docker instead kubernetes, but should work too). |
Beta Was this translation helpful? Give feedback.
-
Ok, a colleague has told me that it is caused by IIS process mode. IIS in in-process mode will not load the libraries, either
Docker / Kubernetes will not use IIS at all, but launches in program mode. So there it will work out of the box, but keep in mind that you have to provide nwrfcsdk linux lib in container. |
Beta Was this translation helpful? Give feedback.
-
ok thanks for the heads up. I didn't know there was a linux specific version of the nwrfcsdk DLLs. I guess I need to log back into SAP and see all the available downloads. |
Beta Was this translation helpful? Give feedback.
-
is the Hosting Model issue specific to net core ? Do I need to worry about that with an asp.net webforms project? |
Beta Was this translation helpful? Give feedback.
-
You don't have to worry. I have reviewed this topic again and finally it can be implemented in a way that work with any process mode / platform. Please have a look at the new samples for aspnetcore. In Program.cs there is a call to a helper set sets the PATH variable (or LD_LIBRARY_PATH on Linux/MacOs): YaNco/samples/WebApi.Shared/RfcLibraryHelper.cs Lines 8 to 16 in 10d8bae I have tested this with .net 471, aspnetcore 2.1 and aspnetcore 3.1. Except for IIS Express in-proc mode and aspnetcore 2.1 it will also work on Windows without setting the path. So behavoir was at least different for .NET Core 2.1. However if you use logic like in the sample you can make sure that it will work in any environment. ContainersPlease note that this don't work for linux containers. Here you have to set the environment variable
for the container. /app is the default path for a dockerfile created in Visual Studio. Debug Configuration / Launch SettingsIn Debug Configuration the logic for containers has changed in Visual Studio 2019, as it will not rebuild the dockerfile in Debug config. Instead you can just add it to the launch settings: YaNco/samples/netcore3.1/SAPWebAPI/Properties/launchSettings.json Lines 32 to 35 in 10d8bae |
Beta Was this translation helpful? Give feedback.
-
that is a lot to unpack. I'm a little confused on the Linux part. Sounds like on a windows machine the variable name is PATH. On a Linux machine the variable name is LD_LIBRARY_PATH However, this is not true in a kubernetes environment? The Linux pods in kubernetes the variable name needs to be /app ? If so, can i change this if(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) to this? if(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
Beta Was this translation helpful? Give feedback.
-
In framework 4.7.2 I get a different error. The DLLs are in bin folder. Is it again looking in PATH location for the DLLs ? |
Beta Was this translation helpful? Give feedback.
-
looks like you are trying to load a x86 library into a x64 process (or x64 into x86 process). See my first answer: |
Beta Was this translation helpful? Give feedback.
-
no. Variable name is always LD_LIBRARY_PATH on Linux. |
Beta Was this translation helpful? Give feedback.
-
OK I will download latest of each version and try both. |
Beta Was this translation helpful? Give feedback.
-
So does that mean the DLLs won't work in containers? |
Beta Was this translation helpful? Give feedback.
-
I've tried both x64 and x86 DLLs and get same error. Do you have any samples of .net framework web application running these DLLs ? |
Beta Was this translation helpful? Give feedback.
-
no, that just means that you have to set the variable, e.g. in dockerfile:
|
Beta Was this translation helpful? Give feedback.
-
https://github.com/dbosoft/YaNco/tree/master/samples/net472/SAPWebAPI this is ASPNET Core 2.1 running on .NET 4.72 however if you mean classic ASP.NET: that has never been tested, and I would not expect it to work as library support starts with .NET Framework 4.71. |
Beta Was this translation helpful? Give feedback.
-
I am trying to use this in these two scenarios:
I got #2 running locally once I set this in the cproj file:
However this is on my local windows machine with IIS Express. According to your previous comments it sounds like I will need to use Linux specific ICU*.dll for the Kubernetes environment. And it also sounds like I will have to modify docker file to set ENV LD_LIBRARY_PATH=/app #1 however, I can't get passed the error I posted before: I've tried both x86 and x64 version of the DLLs and get the same error. And I have verified the DLLs are in the output directory (bin). I'm wondering if I need to programmatically set PATH like you described above in your code sample. |
Beta Was this translation helpful? Give feedback.
-
Ok, understood. In case of the ASP.NET application it already fails to load the sapnwrfc library. So for this environment forget the PATH topic for now. The error " So please check your hosting settings for IIS / IIS Express, to make sure that they use a x64 process model if you load the x64 sapnwrfc.dll. |
Beta Was this translation helpful? Give feedback.
-
Anything else I could be missing? |
Beta Was this translation helpful? Give feedback.
-
I have create a sample WebForms project that loads the library sucessfully: YaNco/samples/webforms/SAPWebForms/Default.aspx.cs Lines 11 to 31 in 352cc37 it cannot do anything except loading sapnwrfc.dll but thats all we need here. During setup of project I first had same problem as you. But I could solve it by switching "Bitness" setting in Project settings / Web to x64. However then the next problem occured. The web projects tried to load the DLL as .NET assembly and was of course failing because it is a C++ DLL. Or you can copy it to c:\windows\system32 (or c:\windows\syswow64 if you would like to use the x86 library). So to summarize this: Instead create a folder somewhere else and include this in the system PATH variable. Then you have also set the path for the ICU libs. |
Beta Was this translation helpful? Give feedback.
-
WebForms sample has been update todo something useful and merged into master: YaNco/samples/webforms/SAPWebForms/Default.aspx.cs Lines 18 to 47 in 0f57fe4 |
Beta Was this translation helpful? Give feedback.
-
Do you know for sure that in a Linux Docker Container environment, the dockerfile needs updated with ENV LD_LIBRARY_PATH=/app ? |
Beta Was this translation helpful? Give feedback.
-
Quite sure actually, at least for the build container. But of course that depends on variables like the container, how you start it and so on.
I would recommend to set it first to /app and if not found check how container is build in your use case. |
Beta Was this translation helpful? Give feedback.
-
as working in updated samples, I close this issue |
Beta Was this translation helpful? Give feedback.
You don't have to worry. I have reviewed this topic again and finally it can be implemented in a way that work with any process mode / platform.
Please have a look at the new samples for aspnetcore. In Program.cs there is a call to a helper set sets the PATH variable (or LD_LIBRARY_PATH on Linux/MacOs):
YaNco/samples/netcore3.1/SAPWebAPI/Program.cs
Line 17 in 10d8bae
YaNco/samples/WebApi.Shared/RfcLibraryHelper.cs
Lines 8 to 16 in 10d8bae