Bug 16555 - Getting build error for monotouch-binding sample 'RouteMe'
Summary: Getting build error for monotouch-binding sample 'RouteMe'
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 0.x Insider Preview
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Joaquin Jares
URL:
Depends on:
Blocks:
 
Reported: 2013-12-03 04:19 UTC by narayanp
Modified: 2015-10-06 17:04 UTC (History)
10 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description narayanp 2013-12-03 04:19:46 UTC
Steps to reproduce:
1. Open VS
2. Open monotouch-binding sample 'RouteMe'
3. Add binding->RouteMe.Touch.csproj in solution.
4. Add reference of RouteMe.Touch into main project(RouteMe)
5. Build the sample.

Actual result: Getting build error "Error	40	Metadata file 'D:\2DEC\monotouch-bindings-master\Route-Me\binding\bin\Debug\RouteMe.dll' could not be found	D:\2DEC\monotouch-bindings-master\Route-Me\samples\sample\CSC	Sample
". This is working fine with XS on Mac

Expected Result: Application should build successfully.

Supplement info:
Build Output: https://gist.github.com/saurabh360/0a0a8be406aed236b0fa

Environment details:
All Windows
VS 2013/2012/2010
MTVS 1.10.19
X.iOS 7.0.5.0
Comment 1 Dave Thomas 2013-12-11 12:03:33 UTC
I could not replicate this issue with the current 1.8.365 build, what version are you using?

How are you building and referencing the actual binding reference? 

Thanks.
Comment 2 Sadik Ali 2013-12-12 06:30:14 UTC
@Dave, we are using following builds:

All Windows 
VS 2013/2012
MTVS 1.10.30
X.iOS 7.0.5-2

I am also getting same issue on Visual Studio. I have observed that "monotouch" assembly reference not found in RouteMe.Touch binding project's references, 

I tried to resolve this issue by adding monotouch.dll file from location "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoTouch\v1.0\monotouch.dll" and build sample application but getting errors: https://gist.github.com/saurabh360/e0a39d3213386dfd8ca4
I have screencast for the same: http://screencast.com/t/idxOeOHy0z 

monotouch-binding sample-4fb9ce4792a74efa85d3a0c435c885254faca7c6/Route-Me

Please check this and let me know if anything required here.
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2014-01-13 15:48:14 UTC
Hi. I just came across this bug while looking for clues about another unrelated bug. I can reproduce the original error ("Metadata file... could not be found") for any pair of library project + app project by:

1. Un-checking "Build" in the "Configuration Manager" for the library project
2. Cleaning the library project.
3. Attempting to build the app project.

So a quick question: is "Build" checked ON in the "Configuration Manager" for the RouteMe binding project in the test setup?
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2014-01-13 17:21:38 UTC
That said, I can't seem to get *any* iOS binding project to build correctly under XamarinVS.iOS 1.10.30 or 1.8.365.

After further investigation, I believe this is an old known limitation:
> http://forums.xamarin.com/discussion/1516/can-i-build-binding-projects-in-visual-studio
> http://forums.xamarin.com/discussion/comment/10363/#Comment_10363

At least until this feature *is* implemented, I think it might be helpful to remove the "Xamarin.iOS Binding Project" template from Visual Studio.



The "Xamarin.iOS Binding Project" template in Visual Studio is also different from the one in Xamarin Studio on Mac:


### Different imported .targets file
The Xamarin Studio template contains:
> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Xamarin.ObjcBinding.CSharp.targets" />

The Visual Studio template contains:
> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />


### <UseMSBuildEngine> element

The Xamarin Studio template contains:
> <UseMSBuildEngine>True</UseMSBuildEngine>

The Visual Studio template does not contain this element.


### Different ProjectTypeGuids

The Xamarin Studio template contains:
<ProjectTypeGuids>{F5B4F3BC-B597-4E2B-B552-EF5D8A32436F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

The Visual Studio template contains:
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>


## An example use case

1. Create a new Xamarin.iOS Binding Project in Visual Studio.

2. Add the following `interface` to the `ApiDefinition.cs` file:
[BaseType(typeof(NSObject))]
public interface Widget
{
    [Export("center")]
    PointF Center { get; set; }
}

3. Build the project.

4. Switch the `.targets` file, add the <UseMSBuildEngine> element, and change the <ProjectTypeGuids> as mentioned above to match the Xamarin Studio values.

5. Attempt to build the project again.


## Result

After step 3:
The project builds, but the resulting .dll contains no types.

After step 5, compile error:
"The type 'System.Drawing.PointF' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Drawing.dll' and 'c:\Program Files (x86)\MSBuild\Xamarin\iOS\monotouch.dll'"


## Result after copying the project to Mac and building with Xamarin Studio

The binding project builds successfully, and the resulting .dll includes the `Widget` type.
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2014-01-15 21:26:38 UTC
In addition to removing the "Xamarin.iOS Binding Project" template, perhaps we could also add a warning or error for projects that have the {F5B4F3BC-B597-4E2B-B552-EF5D8A32436F} GUID? That error can then later be removed when VS supports iOS binding projects.
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2014-04-23 15:15:22 UTC
Filed the request to remove the "Xamarin.iOS Binding Project" template here:
https://bugzilla.xamarin.com/show_bug.cgi?id=19253

And filed the request to add a warning or error message for the {F5B4F3BC-B597-4E2B-B552-EF5D8A32436F} project type here:
https://bugzilla.xamarin.com/show_bug.cgi?id=19256
Comment 7 Kent Green [MSFT] 2014-12-02 16:53:07 UTC
Added closely related bug: https://bugzilla.xamarin.com/show_bug.cgi?id=24673

"Unexpected error - please file a bug report" thrown when attempting to build project; same project builds correctly in Xamarin Studio (Mac)"

As it was noted that the issue is the error is being thrown implying the blocking issue is a bug; where as the root cause is that Binding isn't supported in Visual Studio.
Comment 8 Joaquin Jares 2015-10-06 17:04:17 UTC
Binding samples where redone and should be now fixed in stable.