Xamarin-macios: Native Binding Project Compiles Library With No Methods Or Classes

Created on 21 Jun 2018  路  14Comments  路  Source: xamarin/xamarin-macios

Steps to Reproduce

  1. Create iOS binding project
  2. Build project
  3. Examine output DLL in object browser and see no methods or classes

Expected Behavior

Should have the methods and classes on the dll to use in ios xamarin project

Actual Behavior

Project compiles successfully but DLL has no methods or entry points to use

Environment

Microsoft Visual Studio Community 2017 
Version 15.7.4
VisualStudio.15.Release/15.7.4+27703.2035
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Community

Visual C++ 2017   00369-60000-00001-AA044
Microsoft Visual C++ 2017

Application Insights Tools for Visual Studio Package   8.12.10405.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.40601.0
ASP.NET and Web Tools 2017

C# Tools   2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

Merq   1.1.19-rc (a4ffc1b)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.10.5-pre (ab58725)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

Test Adapter for Boost.Test   1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test.  The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test   1.0
Enables Visual Studio's testing tools with unit tests written for Google Test.  The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools   15.7.20419.2003
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual C++ for Cross Platform Mobile Development (Android)   15.0.27625.00
Visual C++ for Cross Platform Mobile Development (Android)

Visual F# Tools 10.1 for F# 4.1   15.7.0.0.  Commit Hash: 173513e369ffb7a1c4d5dccf83696d9aac2ab2d0.
Microsoft Visual F# Tools 10.1 for F# 4.1

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Visual Studio Tools for Universal Windows Apps   15.0.27703.2035
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Windows Machine Learning Generator Extension   1.0
Windows Machine Learning Visual Studio Extension Detailed Info

Xamarin   4.10.10.2 (35a01d8dc)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   4.12.1 (f3257e429)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK   8.3.3.2 (HEAD/dffc59120)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.12.0.4 (64fece5)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

1>------ Rebuild All started: Project: iXpandBindingslib, Configuration: Release Any CPU ------
1> Connecting to Mac server 192.168.1.126...
1> Connecting to Mac server 192.168.1.126...
1>C:Program Files (x86)Microsoft Visual Studio2017CommunityMSBuild15.0BinMicrosoft.Common.CurrentVersion.targets(3268,5): warning MSB9004: ManifestResourceWithNoCulture item type is deprecated. Emit EmbeddedResource items instead, with metadata WithCulture='false', Type='Resx', and optional LogicalName.
1> iXpandBindingslib -> C:2020CAMRELEASE_4RELEASE_4_XCLIENT_GEN_21CSiXpandBindingslibbinReleaseiXpandBindingslib.dll
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Example Project (If Possible)


iXpandBindingslib.zip

iOS need-info support

Most helpful comment

Fixed the problem. The issue was that the Binding Project was in the same solution as the Xamarin.iOS project so it was not referencing the project correctly. Removed the binding project from the solution, then added the binding project DLL as a reference and now it properly sees the namespace and the methods. I will fix the other issues you mentioned like required frameworks. Thanks for your help! This issue can be closed.

This page helped:

https://forums.xamarin.com/discussion/81795/ios-obj-c-binding-cant-see-namespace

All 14 comments

Hi,

Examine output DLL in object browser and see no methods or classes

So I downloaded your project and build it. If I drag and drop the dll in VSMac I see:

screenshot 2018-06-25 11 17 11

Are you not getting this? Are you talking about something else?

Now I think there might be some issues with the static library (not including required frameworks, see documentation) because when I created an iOS project and tried to use your bindings project I ran into native linker build errors (see gist).

Also you can find help on those build errors with the MT5210 documentation.

Here's your project that I modified that shows the issues: https://www.dropbox.com/s/suos5dmmcwewv4d/iXpandBindingslib.zip?dl=0

Could you please confirm that the binding project itself doesn't output an empty dll (in which case I'll close this bug)?

I was able to recreate dragging the library into VSMac and confirm what you see, the library does have the methods and classes. I was also able to see it by opening the dll directly in the object browser in VS2017 on Windows 10.

The issue is how to reference this library in a Xamarin.iOS project in Windows 10 VS2017. The namespace and methods cannot be found.

I have added it as a normal reference, but when adding a using statement it can't find the namespace iXpandBindingslib.

Is there a correct way to reference this dll in VS2017 on Windows 10 Xamarin.iOS project so it can be used? Should it be listed as a normal reference or a native reference? Why am I unable to see the namespace or use the classes or methods in the Xamarin.iOS project?

Fixed the problem. The issue was that the Binding Project was in the same solution as the Xamarin.iOS project so it was not referencing the project correctly. Removed the binding project from the solution, then added the binding project DLL as a reference and now it properly sees the namespace and the methods. I will fix the other issues you mentioned like required frameworks. Thanks for your help! This issue can be closed.

This page helped:

https://forums.xamarin.com/discussion/81795/ios-obj-c-binding-cant-see-namespace

I confirm having a Bindings Library project in the same solution as iOS app project causes the problem above. Wasted a day trying to figure out the problem until I found this workaround.

@rolfbjarne I believe this issue should be reopened.

@rubo: there are issues with intellisense and binding projects, where intellisense doesn't work correctly and/or show errors (squiggly red lines) in the text editor. These issues can be ignored however, the binding project will build just fine, and you'll be able to reference the binding project from your main project (there might be intellisense issues there as well, but as long as it builds fine, there's nothing to worry about).

I've filed an internal bug to see if we can get intellisense working properly as well.

required framework

I had the same problem. Adding the binding library as reference to another solution worked for me too. Thank you!!!

Thanks to all here for the solution. I lost hours on this. I had created a binding project for some OpenCV code for iOS and was unable to get the namespace to be usable in the project I was binding it to in Xamarin.

Removing the binding project I had made from the solution, building it separately, and then just adding that solution's DLL allowed the binding project's namespace to become usable. Whew.

For those that are new to Xamarin like me, from the target project right-click (or two-finger click on a Mac) on the References folder, select the .Net Assembly tab, browse to the DLL for the bindings project you've already built, and then you should be able to access that namespace and its bindings.

This is confirmed to be working in our solution (in VS2019 161.1 Windows) - the references are found and the iOS application builds, even though intellisense does not work. We did not have to remove the binding projects from the solution for it to build when developing on VSMac.

Removing the binding projects (and we have 3, two of which are third-party and one is binding our own native iOS library) unfortunately forces us to alter our iOS Jenkins pipeline, since we have prebuild custom commands in our binding project(s).

Actually, for me it's not only Intellisense issue. When I am trying to build the main project, MSBuild also returns "_the namespace (and all the related clasees) not available_".
More weird is that this happens only in Release mode. When selecting Debug (and what's more interesting, independently on what project is actually selected in Startup project dropdown(!)), it works fine. So, definitely a quite weird bug of Visual Studio.
But removing Binding projects from the solution does help, yes.

Fixed the problem. The issue was that the Binding Project was in the same solution as the Xamarin.iOS project so it was not referencing the project correctly. Removed the binding project from the solution, then added the binding project DLL as a reference and now it properly sees the namespace and the methods. I will fix the other issues you mentioned like required frameworks. Thanks for your help! This issue can be closed.

This page helped:

https://forums.xamarin.com/discussion/81795/ios-obj-c-binding-cant-see-namespace

Thank you for this!!! Finally it fixed my problem.

Fixed the problem. The issue was that the Binding Project was in the same solution as the Xamarin.iOS project so it was not referencing the project correctly. Removed the binding project from the solution, then added the binding project DLL as a reference and now it properly sees the namespace and the methods. I will fix the other issues you mentioned like required frameworks. Thanks for your help! This issue can be closed.

This page helped:

https://forums.xamarin.com/discussion/81795/ios-obj-c-binding-cant-see-namespace

Thanks you for this!!! because of this, I made a Stack Overflow question to figure it out lol.

I feel like this is absolutely a bug and should be reopened? The suggest workaround does get around this issue, sure, but it is a workaround - not being able to reference the bindings project using a project reference within the same solution causes all sorts of problems with build pipelines and stale cached dlls in bin folder etc.

Also, the same functionality works just fine for a Java bindings project in Xamarin.Android...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chamons picture chamons  路  4Comments

ormaa picture ormaa  路  3Comments

nickmask picture nickmask  路  3Comments

Mikilll94 picture Mikilll94  路  4Comments

jzeferino picture jzeferino  路  3Comments