How to add and use a C++ dll in a UWP project - dll

I have created a UWP project in Visual Studio 2017. And I need to access some methods of a C++ dll from my UWP project. For that I have added the C++ dll in the \bin folder of the UWP project. And while debugging, it's showing some errors like
"Unable to load DLL 'testDll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
So I have copied the C++ dll into the \AppX folder. So the error is not showing but it's not working with the C++ dll.
Is there any steps to use a C++ dll in UWP project?
I have seen a step in google which is add the path of the library in the Additional Dependencies property of the UWP project (in Configuration Properties > Linker ) but I can't find the Linker option in configuration properties.
Could you please anyone help me with this.

Related

Adding DLL in Visual Studio 2013 causes Compiler Error -107374181 (ERROR_ACCESS_DENIED)

I am trying to add a reference to a dll, but when I compile the project I get:
Compiler Error Message: The compiler failed with error code -1073741819.
I have tried:
changing the security permissions on the dll to allow full control
running visual studio as administrator.
I have added the dll with copylocal = false, but it fails at runtime with a "file not found" error.
I created a separate project with the same framework version (4.5) and was able to add the dll without any trouble, but unfortunately I need to add it to the existing legacy project.
The legacy project source files are in GitHub, but the bin folder where I am adding the DLL to is not in Github.

"Librarian" rather than "Linker" shown in VS2015 DLL project

I have a DLL project in Visual Studio 2015 with properties:
However on the left hand side, I see "Librarian" rather than "Linker" options. Also on build I get undefined symbols for all referenced libraries (the project references a few projects in the solutions which build as static lib).
To note:
I converted the project from a static lib to a DLL by changing the "Configuration Type" option.
I have applied, saved, closed, reopened
Linked projects are of same type (e.g. Debug/x64) for this solution configuration.
This could be a VS2015 bug?
Note perhaps similar question for previous version of Visual Studio
In Visual Studio 2012 what is the difference between Librarian and Linker?
(however the question doesn't specify that it's a DLL project)
The problem is that the DLL project had a property sheet which sets the project as a static library, and had a libraries section.
It seems setting your project settings to DLL cannot override this kind of property sheet.

Reference from assembly to DLL in Visual Studio solution

Say, that we have .NET application App along with additional assembly ClassLibrary, which, in turn, uses native DLL called Library. All these are in single solution, so I may set up the dependencies etc.
The catch is, that I want the Library to be automatically "attached" to ClassLibrary, such that when my App references it, Visual Studio will automatically copy the Library to target bin folder.
Usually I did that by using pre-build or post-build events and adding custom scripts. But hey, all these are in the same solution. Is there simpler way to keep such native-dll-reference for .NET assembly?
You have to add the native library to your project. If the native library is in the Solution (not in the project) than it is there only for your reference. You have to add the native library to the Project because the project file describe the build behaviour.
Than add native assembly to the ClassLibrary project and then in properties set: Copy To Output Directory to Copy if newer or Copy always.

Cannot add a reference to PCL from C++/Cli project

I have a Portable Class Library project, Net 4.5 platform activated. I can use it in other C# projects without problems.
Now, I have a C++/Cli project and I need to use some classes of the above PCL project.
When I add the reference to the PCL project, Visual Studio 2012 gives me an error because of different target platforms.
Is there a problem to add references to PCL projects from C++/Cli projects?
Thank you
This questionas was replied but for some unknown reason, the response has been deleted:
The solution is to edit the vcxproj file and change
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
to
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

Build a Windows Phone 8 project with c++ WinRT component from command line

I am trying to build a Windows Phone 8 project which contains a reference to a WinRT component project written in C++. The project builds from VS2012 IDE but doesn't build from the command line using the MSBuild (c:\Windows\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe). It throws this error:
WindowsPhoneRuntimeComponent1\WindowsPhoneRuntimeComponent1.vcxproj(185,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\WindowsPhone\v7.0\Microsoft.Cpp.WindowsPhone.7.0.targets" was not found. Confirm that
the path in the <Import> declaration is correct, and that the file exists on disk.
My assumption judging on the required target file is that it tries to build a WP8 project for WP7. Does anyone know how to work around this issue, or if there is a possible solution to this problem?
You need to change your project to WP8. Right click on your project, choose Properties. Under the Application tab change the type from WP7 to WP8. Hope that works.