Integrating Visual C++ on .NET Framework 2.0 with C# Library - c++

I am familiar with C# programming. Today I need to integrate one Visual C++ program on .NET Framework 2.0 with my C# library. After referencing my C# library, a new C++ class is created. But the following line cannot be compiled in the new class.
using namespace MyCSharpLibSpace;
The error is that "The namespace does not exist". Why? I think I can use the namespace after referencing it, right?
I also did another trial on .NET Framework 3.5. I created a simple HelloWorld Visual C++ project. It works fine. What I did is the same as above. It seems that it is different to integrate Visual C++ program with C# library on 3.5 and 2.0? How to do that on 2.0?
I appreciate so much for your help!
Bing

Related

Android Studio, Adding Native C++ Code via JNI to a Second Activity of an Android App

I'm using Android Studio to build an Android app. I'm using Kotlin, and I'm using C++ code, i.e. native C++ that I interface with using JNI. I'm able to do this in the MainActivity, because Android Studio offers this build in their setup. However, I can't figure out a way to call native C++ functions from a second empty activity that I created. Does anyone know how to set up a second activity to access native C++ code?
Thanks for any help!

How to install npgsql for c++ in Visual Studio 2017

sorry if this is too simple to be of help to most people.
This is the first time I have done anything remotely like this and it appears that my problem is too unadvanced to be covered in any documentation.
I am trying to connect a c++ project in Visual Studio 2017 to a PostgreSQL database.
Just to be clear, I know how to run pgAdmin/host databases, code in C++, and I think I could handle the npgsql syntax if I got it working.
However, I've never used .NET (although 4.5 is on my computer).
Here's what I am doing:
I start an empty project for C++ in Visual Studio 2017.
I open nuget manager and search npgsql, but my project is pointing to native,v0.0 instead of a .NET framework.
So I target v4.5 in the .NET framework property, but that doesn't change anything.
Could someone please tell if what I am trying to do is possible?
Should I be using a different project other than empty project?
Does this need to be some kind of web application?
If it is possible I'd love any advice on how to do it.
If you are writing a native c++ program it is very unlikely you want to bring in a .net assembly. If you want to connect to a pg database I would suggest instead that you use the odbc driver (https://odbc.postgresql.org/) or perhaps there is some library available as part of PG, but using a .net assembly will require a great deal of unnecessary interop work.

Which features of .NET framework do interop assemblies reference?

We have a Visual Studio solution with about 90 projects. Most of them are built to DLL files, some are written in C++, others in C#. The projects communicate with each other via COM. We use tlbexp to generate TLB files of some C# projects (the ones that are referenced in C++ projects). And we use tlbimp to generate interop DLLs of the C++ projects. I did not completely dig into the topic, but I think, the interop files just define the interfaces of the C++ classes, to make them usable from other projects is that right?
Now, the question is the following: In order to upgrade the entire solution to Visual Studio 2015 and let it compile against .NET 4.6.1, I inspected the resulting assemblies using dotPeek by JetBrains. I can see, that all the C# projects are correctly using .NET 4.6.1, the C++ DLLs themselves are native and do not reference any .NET. Now, what surprised me was the fact, that dotPeek told me, the interop DLLs (which resulted from the C++ projects), were referencing .NET 4.0.
After a "wonderful" day of trying to make them reference .NET 4.6.1 and lots of research, I finally did not find any way to make the interops reference .NET 4.6.1. Is that even possible? My current guess is, that all interop DLLs generated like this reference just the basic .NET 4.0, just because it uses the same CLR as .NET 4.6.1.
Is that right? It should be possible to execute the assemblies on any system that has .NET Framework 4.6.1 installed, shouldn't it?
You are getting bad info from dotPeek. It doesn't tell you how it figured out what .NET version is targeted. It can be specific on a .NET assembly that's generated by a compiler. Because it automatically inserts a [TargetFramework] attribute into the assembly, it states what version of .NET you selected when you built the project.
But an interop assembly does not specify a .NET version, primarily because it isn't generated by a compiler. Note how you never specified a version when you ran Tlbimp.exe. And can't. All that dotPeek can figure out is that it targets .NET 4, cued by the metadata format. No way it can be more specific.
And it does not matter, since the interop library does not use .NET Framework features. The only point of the library is that your program can use the COM component features. So the version number that dotPeek reports just doesn't matter; any .NET 4.x framework can use the library.
You don't have a real problem.

Pjsip2.2 PJSUA2 API for iOS

I've upgraded pjsip 2.2 with the new PJSUA2 API.
It's written in C++ and the documentation has given the use example for Java/Python applications as well. But I can't find any example for iOS application.
I'm not very familiar with using C++ in Objective-C. I was trying to replace the existing pjsua.h with pjsua2.hpp... It seems not even linked to the lib.
Any advice?

Porting C++ Project to Android

I have a big C++ application developed on windows,I need to port it to Android to run it as galaxy tab application.
I read many tutorials about NDK but it seems difficult to embed C++ files into Android.
Can I develop "DLL" using NDK? and invoke DLL from DLL?
any help would be highly appreciated .
Starting with 2.3, you can write android-applications completely in C++. Prior to 2.3, you had to create a shared object (the Linux equivalent of a DLL) using JNI, and call this from Java.