Bug 29232 - BI0000 - Nullpointer exception when using bmac for very simple simple framework
Summary: BI0000 - Nullpointer exception when using bmac for very simple simple framework
Status: RESOLVED ANSWERED
Alias: None
Product: MonoMac
Classification: Desktop
Component: Bindings ()
Version: GIT
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2015-04-19 20:30 UTC by Lucas van Dongen
Modified: 2015-07-02 11:45 UTC (History)
1 user (show)

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


Attachments
The ApiDefinitions file (204 bytes, application/octet-stream)
2015-04-19 20:30 UTC, Lucas van Dongen
Details


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 or GitHub 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 ANSWERED

Description Lucas van Dongen 2015-04-19 20:30:53 UTC
Created attachment 10814 [details]
The ApiDefinitions file

When I try to convert my very simple test .framework I run into problems when I try to use mac

Header:
#import <Cocoa/Cocoa.h>

//! Project version number for Simple.
//FOUNDATION_EXPORT double SimpleVersionNumber;

//! Project version string for Simple.
//FOUNDATION_EXPORT const unsigned char SimpleVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <Simple/PublicHeader.h>

@interface Simple : NSObject

- (NSString *)run;

@end

Implementation:
#import "Simple.h"

@implementation Simple

- (NSString *)run
{
    return @"OK";
}

@end

Command used:

MacBook-Pro:Frameworks User$ mono /Users/User/Code/monomac/monomac/src/bmac.exe -o Simple2.dll --tmpdir=/tmp -baselib=/Users/User/Code/monomac/monomac/src/MonoMac.dll -r=System.Drawing ApiDefinitions.cs -v
mcs -sdk:4 -debug -unsafe -target:library ApiDefinitions.cs -nowarn:436 -out:/tmp/temp.dll -r:/Users/User/Code/monomac/monomac/src/bmac.exe  -r:System.Drawing -unsafe -r:/Users/User/Code/monomac/monomac/src/MonoMac.dll   
error BI0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
System.NullReferenceException: Object reference not set to an instance of an object
  at Generator.Generate (System.Type type) [0x00000] in <filename unknown>:0 
  at Generator.Go () [0x00000] in <filename unknown>:0 
  at BindingTouch.Main2 (System.String[] args) [0x00000] in <filename unknown>:0 
  at BindingTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Chris Hamons 2015-07-02 11:45:35 UTC
@Lucas - I took a look at your example and have a few questions/comments.

- Your binding is not in a namespace. Having all of your code in a namespace is generally a good idea.
- It appears you are using the open source MonoMac framework. Just FYI - we've made a number of improvements with binding generation / bmac in Xamarin.Mac. 
- https://developer.xamarin.com/samples/mac/XMBindingExample/ uses Xamarin.Mac, but is a good example of the process start to finish.
- I believe (at least one of) the problems you are running into is due to the name of your binding file. Our binding generator uses the file name by default to generate the .NET namespace to output code to, and '-' is not a valid character.

You can sometimes dig into issues with our code generator by using --sourceonly=files.txt and opening the files listed there to see what was generated.

Let me know if that solves your issue.