Import C# application to Andriod

We are planning to import C# application to Andriod the structure is as listed

Create a DLL CPP project which uses MFC
Use this DLL in Interop Project which is again a CPP project
C# library Project which uses this Interop in following way
[DllImport("Interop.dll")]
static extern void Interop_TravelCallback(IntPtr handle, Travel handler);

Add the reference of this C# library to VB.net UI Project and calls required method
Is it possible to migrate such structure to Android?

Best regards
Yogesh Parab

Best Answers

  • JonathanPryorJonathanPryor US Xamurai
    Accepted Answer

    So if I have C# UI Project which uses C# library which is using C++ DLL using "DLL Import" syntax, than same can imported to Andriod

    Yes, as long as the C++ native library can be compiled for Linux/Android.

    If C++ DLL/Project is using MFC than we cant import the above case as Andriod doesn't support MFC

    Correct.

    It would be difficult to import if the VB.net UI project is used instead of C# Project

    There are two problems there:

    1. Any pre-existing "VB.net UI project" will be using a non-Android UI, e.g. System.Windows.Forms or WPF. Neither of those will work on Android.
    2. Xamarin.Android does not provide VB.net support, so you can't create Android-specific UI code in VB.NET.

Answers

  • YogeshParabYogeshParab INMember

    Thanks Jonathan,

    So if I have C# UI Project which uses C# library which is using C++ DLL using "DLL Import" syntax, than same can imported to Andriod

    If C++ DLL/Project is using MFC than we cant import the above case as Andriod doesn't support MFC

    It would be difficult to import if the VB.net UI project is used instead of C# Project

    Hope my understanding is right.

    Best Regards
    Yogi

  • IvanHarrisIvanHarris USMember ✭✭✭

    You still need to learn Android UI (XML) to create your activities. C# code can be used in to code.

  • YogeshParabYogeshParab INMember

    Thanks Ivan.

    I don't think my query was interpreted right, as per my understanding from earlier response I wanted confirm on below mentioned points as listed

    "So if I have C# UI Project which uses C# library which is using C++ DLL using "DLL Import" syntax, than same can imported to Andriod"
    Is right that this kind of structure can be ported to andriod

    "If C++ DLL/Project is using MFC than we cant import the above case as Andriod doesn't support MFC"
    Is it right that due to use of MFc in the C++ project we cant import this kind of project to Andriod

    "It would be difficult to import if the VB.net UI project is used instead of C# Project"
    Is it right that VB.net cant be ported to andriod as related Project templates are not provided.

    You still need to learn Android UI (XML) to create your activities. C# code can be used in to code
    So what I understand over here is that one need to create/learn Andriod UI and C# code can be used and code behind and we are fine with that

    Best Regards
    Yogi

  • JonathanPryorJonathanPryor USXamarin Team Xamurai
    Accepted Answer

    So if I have C# UI Project which uses C# library which is using C++ DLL using "DLL Import" syntax, than same can imported to Andriod

    Yes, as long as the C++ native library can be compiled for Linux/Android.

    If C++ DLL/Project is using MFC than we cant import the above case as Andriod doesn't support MFC

    Correct.

    It would be difficult to import if the VB.net UI project is used instead of C# Project

    There are two problems there:

    1. Any pre-existing "VB.net UI project" will be using a non-Android UI, e.g. System.Windows.Forms or WPF. Neither of those will work on Android.
    2. Xamarin.Android does not provide VB.net support, so you can't create Android-specific UI code in VB.NET.
  • LangLangLangLang USMember

    Hello, I am new to Xamarin.
    I met similar problem to this forum's topic.
    I have one opencv application project that was built on MFC.
    Now, I want to use this source project to build cross-platform mobile app by Xamarin.
    I saw that MFC dll can't not be imported in Xamarin code.
    Is there any other way to accomplish my goal?
    I referred this link.
    http://kerry.lothrop.de/c-libraries/
    Hope to get response from professionals.

Sign In or Register to comment.