[Mono-osx] MonoMac NSTableView Scroll Crash
Landon Campbell
campbelllandon at hotmail.com
Fri Mar 1 17:08:33 UTC 2013
Hi everybody,
I'm a MonoMac noob, and I'm trying to get an NSTableView to work in my application. I followed two examples to implement my solution:
http://www.milkcarton.com/blog/2010/07/05/Databinding+To+An+NSTableView+With+A+MonoMac+App.aspxhttp://www.netneurotic.net/Mono/MonoMac-NSTableView.html
I created a datasource class according to these articles, and my NSTableView loads the data without any problem. Here's the basic code:
DataSource class:[Register("TableViewDataSource")]public class DashboardReportDataSource : NSTableViewDataSource{ private List<Reseller> _resellers;
public DashboardReportDataSource () { var domainRepository = new DomainRepository(); _resellers = domainRepository.GetClientResellers(161); }
[Export("numberOfRowsInTableView:")] public int NumberOfRowsInTableView (NSTableView tableView) { if (_resellers == null) { return 0; else { return _resellers.Count; } }
[Export("tableView:objectValueForTableColumn:row:")] public NSObject objectValueForTableColumn (NSTableView aTableView, NSTableColumn aTableColumn, int rowIndex) { switch (aTableColumn.Identifier.ToString()){ case "colProductId" : return new NSString(_resellers[rowIndex].Id.ToString()); case "colResellerId" : return new NSString(_resellers[rowIndex].Name); default: return new NSString(""); } }}
Populate table in my custom NSView class:public override void LoadView (){ base.LoadView (); tblDashboardReport.DataSource = new DashboardReportDataSource();}
My domain repository calls SQL Server and populates the generic list. Like I said, the load is fine (actually super-fast), but if I scroll to the bottom of my table view, then start to scroll back up, the app crashes, every single time. This is the error I'm getting:
System.MissingMethodException: No constructor found for DashboardReportDataSource::.ctor(System.IntPtr) at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000fd] in /Users/builder/data/lanes/mono-mac-ui-refresh-2-10/2baeee2f/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.11/_build/mono-2.10.11.git/mcs/class/corlib/System/Activator.cs:280 at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in /Users/builder/data/lanes/mono-mac-ui-refresh-2-10/2baeee2f/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.11/_build/mono-2.10.11.git/mcs/class/corlib/System/Activator.cs:234 at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in /Users/builder/data/lanes/mono-mac-ui-refresh-2-10/2baeee2f/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.11/_build/mono-2.10.11.git/mcs/class/corlib/System/Activator.cs:229 at MonoMac.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x00000] in <filename unknown>:0 at MonoMac.ObjCRuntime.NSObjectMarshaler`1[MonoMac.Foundation.NSObject].MarshalNativeToManaged (IntPtr handle) [0x00000] in <filename unknown>:0 at (wrapper native-to-managed) object:[DashboardReportDataSource:MonoMac.Foundation.NSObject objectValueForTableColumn(MonoMac.AppKit.NSTableView, MonoMac.AppKit.NSTableColumn, Int32)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.AppKit.NSTableView,MonoMac.AppKit.NSTableColumn,int) at (wrapper managed-to-native) MonoMac.AppKit.NSApplication:NSApplicationMain (int,string[]) at MonoMac.AppKit.NSApplication.Main (System.String[] args) [0x00000] in <filename unknown>:0 at BPA.UI.Mono.Mac.MainClass.Main (System.String[] args) [0x00005] in /Users/User/Projects/Repositories/BPA.UI.Mono/BPA.UI.Mono.Mac/Main.cs:14
Seems like an odd issue, since it claims the class doesn't have a constructor, which it obviously does. I could really use some help -- does anybody have any idea what I'm doing wrong?
System:Mono 2.10.11MonoDevelop 3.1.1XCode 4.6Lastest MonoMac add-in (Xamarin.Mac 3.1.1, open-source)Mac OS X Lion (running in VMWare Player)
Thanks for you help,Landon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-osx/attachments/20130301/0719d0f8/attachment.html>
More information about the Mono-osx
mailing list