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

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>

Related

convert old C++ Winrt dll project based on sample to Windows Run-time Component project

I have old C++ Winrt dll project created from C++ WInrt Sample, before project templates were available.
How do i update it to Winrt Runtime Component Project Template, without starting from new project.
I have checked project settings cant find anything conclusive that make both projects differ, but The new style projects work better with Runtime components, specifically you dont get error saying versions of Winrt are different when you try to access Idl generated header files.
Cheers
As documented at Introduction to C++/WinRT: Visual Studio support for C++/WinRT, and the VSIX:
Alternatively, you can convert an existing project by adding the <CppWinRTEnabled>true</CppWinRTEnabled> property to its .vcxproj file.
<Project ...>
<PropertyGroup Label="Globals">
<CppWinRTEnabled>true</CppWinRTEnabled>
...
Once you've added that property, you'll get C++/WinRT MSBuild support for the project, including invoking the cppwinrt.exe tool.

VS2015 C++ DLL and such with Add Reference

I have three VS2015 projects (DLL, C++ App & C# App)
I created the DLL and targeted v4.5 Framework
I created the C++ Application and targeted the v4.5 framwork and then was able to add reference without an issue.
I create the C# Application and targeted the v4.5 framework and then the Add reference fails with check your assembly or COM message.
Both applications have the DLL project added to the solution.
What else can I check as to why my C# process can't add reference?
Thanks,
Mark
I got around it using PInvode and the C# project didn't need to Add Reference afterall. I had to manually edit out the Precompiled header stuff to force that NotUsing. Thanks for the quick response... just had a quick turn around for my boss. Handed a working Cipher DLL for use with both C++ and C# in his project.

VB.NET DLL not possible in a Xamarin.Forms app?

I'm trying to reference a VB.NET DLL in a Xamarin.Forms (Portable) application. During the course of my research, I found the following post that might allow this: Xamarin.Android and VB.Net Libraries
I've tried to use the "Embed" work-around mentioned in the link, but the Xamarin.Forms project would fail to build because it can't load the Microsoft.VisualBasic assembly, version 8.0.0.0.
I've also found the following link as well during my research that should allow at least some VB.NET usage in a Xamarin application: https://developer.xamarin.com/guides/cross-platform/application_fundamentals/pcl/portable_visual_basic_net/xamarin-forms/
At the bottom of the site, there is a "Limitations of VB.NET in Xamarin.Forms" section. With the last item: "Xamarin does not support the Visual Basic.NET language," does that simply mean that you can't use a VB.NET dll in any Xamarin.Forms (portable) project that happens to also reference Xamarin.Forms.Core, Xamarin.Forms.Platform, and Xamarin.Forms.Xaml?
Thanks for any insight!
A DLL doesn't contain it's dependencies. If your DLL relies on Microsoft.VisualBasic, you will need to load the DLL that contains that assembly as well.
So either remove the Microsoft.VisualBasic assembly reference from the VB DLL, or include it as a reference in your Xamarin project (which may or may not be possible, I am not sure.)

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.

Why am I unable to add my PCL to my Universal App?

I get "Unable to add reference" when I try to add my PCL as reference. The projects are in the same solution. The error message doesn't say anything more.
When I try to add the .dll via Browse... I get the an error telling me that I can not add a PCL targeted at .NET Framework to a project targeting .NETCore.
What's wrong?
It sounds like the library you think is a PCL is not actually a Portable Class Library. It's just a .NET Framework library.
Try creating a new PCL and referencing that. See this MSDN page for information on how to create a PCL.
The error is that your PCL is targeted at .NET Framework and not .NETCore. .NETCore does only contain a subset of .NET Framework.
To solve this, replace your PCL project with a Class Library (Portable for Universal Apps).