I have c++ library (.dll) which is exposing few methods, i want to consume those methods in UWP application. The methods will call frequently from UWP application.
Can you please provide the solution on this.
Welcome to our Microsoft Q&A platform!
If you want to use c++ methods in UWP, the first suggestion is to wrap that C++ logic using a WinRT component.
But if you want to directly use your c++ library, you can PInvoke the dll. You need to follow these steps (You can also refer to this thread for more details):
First, add .dll into your UWP project making sure to set its type as 'content'.
Then in the proper .cs file, using DllImport to PInvoke the dll. And here is a similar thread, you can refer to it.
The UWP platform doesn't support all of the standard Win32 file APIs. From looking at your error it appears that the "log file" component you are using is trying to use the standard Win32 file I/O and failing.
While some of the Win32 file APIs are supported there are a number of limitations. You will need to update the C++ code to use file APIs that work as expected from the UWP environment and / or make sure that you are accessing storage locations that are available from your UWP app.
For example: When called from a Windows Store app, CreateFile2 is simplified. You can open only files or directories inside the ApplicationData.LocalFolder or Package.InstalledLocation directories.
In most cases we recommend retrofitting your code to use the StorageFile APIs for easy interaction with the WinRT components. I've included links below.
Alternatives to Windows APIs in Universal Windows Platform (UWP) apps
APIs present on all Windows 10 devices
I hope this helps,
8 people are following this question.