I have read the documentation from Xamarin.
And this is my test class in Objective-C:
#import "XamarinBundleLib.h"
@implementation XamarinBundleLib
+(NSString *)testBinding{
return @"Hello Binding";
}
@end
It's very easy, just one method.
And this is my C# class:
namespace ResloveName
{
[BaseType (typeof (NSObject))]
public partial interface IXamarinBundleLib {
[Static,Export ("testBinding")]
NSString TestBinding {get;}
}
}
Then this is my AppDelegate code:
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method
string testStr = ResloveName.IXamarinBundleLib.TestBinding.ToString ();
System.Console.WriteLine ("testStr="+testStr);
return true;
}
When I run the application, I get this exception:
The TestBinding attributes is null. I must be wrong somewhere, so how can I fix it?
See Question&Answers more detail:os