Exception when run Aspnet Mvc app on OS X - asp.net-mvc

I'm trying to run samples for aspnet 5 on os x:
git clone https://github.com/shirhatti/Home.git
When I build the project HelloMvc -- 'kpm build' -- it's ok.
Then I run app using 'k kestrel' and see the following error:
Missing method Microsoft.Framework.Runtime.ILibraryInformation::get_LoadableAssemblies() in assembly data-0x7feb6aa02a00, referenced in assembly /Users/minya/.kpm/packages/Microsoft.AspNet.Mvc.Core/6.0.0-beta2-11905/lib/aspnet50/Microsoft.AspNet.Mvc.Core.dll
System.MissingMethodException: Method not found: 'Microsoft.Framework.Runtime.ILibraryInformation.get_LoadableAssemblies'.
at System.Linq.Enumerable+c__Iterator122[Microsoft.Framework.Runtime.ILibraryInformation,System.Reflection.AssemblyName].MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator102[System.Reflection.AssemblyName,System.Reflection.Assembly].MoveNext () [0x00000] in :0
at System.Linq.Enumerable+c__Iterator122[System.Reflection.Assembly,System.Reflection.TypeInfo].MoveNext () [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Mvc.ControllerActionDescriptorProvider.BuildModel () [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Mvc.ControllerActionDescriptorProvider.GetDescriptors () [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Mvc.ControllerActionDescriptorProvider.Invoke (Microsoft.AspNet.Mvc.ActionDescriptorProviderContext context, System.Action callNext) [0x00000] in <filename unknown>:0
at Microsoft.Framework.DependencyInjection.NestedProviders.NestedProviderManager1+CallNext[Microsoft.AspNet.Mvc.ActionDescriptorProviderContext].CallNextProvider () [0x00000] in :0
at Microsoft.Framework.DependencyInjection.NestedProviders.NestedProviderManager1[Microsoft.AspNet.Mvc.ActionDescriptorProviderContext].Invoke (Microsoft.AspNet.Mvc.ActionDescriptorProviderContext context) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Mvc.DefaultActionDescriptorsCollectionProvider.GetCollection () [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Mvc.DefaultActionDescriptorsCollectionProvider.get_ActionDescriptors () [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Mvc.Routing.AttributeRouting.GetActionDescriptors (IServiceProvider services) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Mvc.Routing.AttributeRouting.CreateAttributeMegaRoute (IRouter target, IServiceProvider services) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Builder.BuilderExtensions.UseMvc (IApplicationBuilder app, System.Action1 configureRoutes) [0x00000] in :0
at Microsoft.AspNet.Builder.BuilderExtensions.UseMvc (IApplicationBuilder app) [0x00000] in :0
at KWebStartup.Startup.Configure (IApplicationBuilder app) [0x00000] in :0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
There is no exact problem in google. I was tried to reinstall kvm, delete and checkout NuGet deps.
Updated:
Similar behavior on Windows when I try to run the same project by 'k web':
System.MissingMethodException: Method not found: 'System.Collections.Generic.IEnumerable1<System.Reflection.AssemblyName> Microsoft.Framework.Runtime.ILibraryInformation.g
et_LoadableAssemblies()'.
at Microsoft.AspNet.Mvc.DefaultAssemblyProvider.<>c__DisplayClass0.<get_CandidateAssemblies>b__1(ILibraryInformation l)
at System.Linq.Enumerable.<SelectManyIterator>d__142.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__142.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext()
at Microsoft.AspNet.Mvc.ControllerActionDescriptorProvider.BuildModel()
at Microsoft.AspNet.Mvc.ControllerActionDescriptorProvider.GetDescriptors()
at Microsoft.AspNet.Mvc.ControllerActionDescriptorProvider.Invoke(ActionDescriptorProviderContext context, Action callNext)
at Microsoft.Framework.DependencyInjection.NestedProviders.NestedProviderManager1.CallNext.CallNextProvider()
at Microsoft.Framework.DependencyInjection.NestedProviders.NestedProviderManager1.Invoke(T context)
at Microsoft.AspNet.Mvc.DefaultActionDescriptorsCollectionProvider.GetCollection()
at Microsoft.AspNet.Mvc.DefaultActionDescriptorsCollectionProvider.get_ActionDescriptors()
at Microsoft.AspNet.Mvc.Routing.AttributeRouting.GetActionDescriptors(IServiceProvider services)
at Microsoft.AspNet.Mvc.Routing.AttributeRouting.CreateAttributeMegaRoute(IRouter target, IServiceProvider services)
at Microsoft.AspNet.Builder.BuilderExtensions.UseMvc(IApplicationBuilder app, Action1 configureRoutes)
at Microsoft.AspNet.Builder.BuilderExtensions.UseMvc(IApplicationBuilder app)
at HelloMvc.Startup.Configure(IApplicationBuilder app) in C:\prj\Home\samples\HelloMvc\Startup.cs:line 18
Seems to be the problem is in one (or more) of referenced in Microsoft.AspNet.Mvc.* assemblies. This is disassemble of DefaultAssemblyProvider from Microsoft.AspNet.Mvc.Core. I guess the problem is in ILibraryManager's implementations GetReferencingLibraries() method. But I can't find this implementation.
public class DefaultAssemblyProvider : IAssemblyProvider
{
private static readonly HashSet<string> _mvcAssemblyList;
private readonly ILibraryManager _libraryManager;
public IEnumerable<Assembly> CandidateAssemblies
{
get
{
return Enumerable.Select<AssemblyName, Assembly>(Enumerable.SelectMany<ILibraryInformation, AssemblyName>(this.GetCandidateLibraries(), DefaultAssemblyProvider.\u003C\u003Ec__DisplayClass0.CS\u0024\u003C\u003E9__CachedAnonymousMethodDelegate2 ?? (DefaultAssemblyProvider.\u003C\u003Ec__DisplayClass0.CS\u0024\u003C\u003E9__CachedAnonymousMethodDelegate2 = new Func<ILibraryInformation, IEnumerable<AssemblyName>>(DefaultAssemblyProvider.\u003C\u003Ec__DisplayClass0.CS\u0024\u003C\u003E9__inst.\u003Cget_CandidateAssemblies\u003Eb__1))), new Func<AssemblyName, Assembly>(DefaultAssemblyProvider.Load));
}
}
static DefaultAssemblyProvider()
{
HashSet<string> hashSet = new HashSet<string>((IEqualityComparer<string>) StringComparer.Ordinal);
string str1 = "Microsoft.AspNet.Mvc";
hashSet.Add(str1);
string str2 = "Microsoft.AspNet.Mvc.Core";
hashSet.Add(str2);
string str3 = "Microsoft.AspNet.Mvc.ModelBinding";
hashSet.Add(str3);
string str4 = "Microsoft.AspNet.Mvc.Razor";
hashSet.Add(str4);
string str5 = "Microsoft.AspNet.Mvc.Razor.Host";
hashSet.Add(str5);
string str6 = "Microsoft.AspNet.Mvc.Rendering";
hashSet.Add(str6);
DefaultAssemblyProvider._mvcAssemblyList = hashSet;
}
public DefaultAssemblyProvider(ILibraryManager libraryManager)
{
this._libraryManager = libraryManager;
}
internal IEnumerable<ILibraryInformation> GetCandidateLibraries()
{
return Enumerable.Where<ILibraryInformation>(Enumerable.Distinct<ILibraryInformation>(Enumerable.SelectMany<string, ILibraryInformation>((IEnumerable<string>) DefaultAssemblyProvider._mvcAssemblyList, new Func<string, IEnumerable<ILibraryInformation>>(this._libraryManager.GetReferencingLibraries))), new Func<ILibraryInformation, bool>(DefaultAssemblyProvider.IsCandidateLibrary));
}
private static Assembly Load(AssemblyName assemblyName)
{
return Assembly.Load(assemblyName);
}
private static bool IsCandidateLibrary(ILibraryInformation library)
{
return !DefaultAssemblyProvider._mvcAssemblyList.Contains(library.get_Name());
}
}

I had a similar problem on Windows and found the wrong KRE was active.
Executing kvm list shows a list of KRE. In my case the 1.0.0-alpha4 version was active instead of the more recent beta version.
Switching to the default with kvm use default sorted it out for me.

I was able to resolve this error by updating my version of KVM, there is probably a simpler way but, assuming you initially installed using homebrew, running these commands should solve your issue
brew untap aspnet/k
brew tap aspnet/k
brew install kvm
then you should be able to run k kestrel
if you get a message that kvm is already installed then:
brew link --overwrite mono
brew uninstall mono
brew reinstall kvm

Related

Xamarin Form: ListView causing Specified argument was out of the range of valid values. Parameter name: index

I have tried a lot of combination to test the code in LoadData function.
The first time the Page loaded, the LoadData function got called. Later user change the date which causing the LoadData function to be called again. This time there was an error quoted below. If I commented the Collection = programs line, the code have no problem.
The problem even if the programs has 0 item in the second execution of the function.
public async Task LoadData (DateTime day)
{
this.day = day;
var programs = await new ECEProgramLogic().GetGrouppedProgram(day.Date, actionNameType);
Collection = programs;
}
private ObservableCollection<GroupViewModel<object>> collection;
public ObservableCollection<GroupViewModel<object>> Collection
{
get
{
return collection;
}
set
{
collection = value;
Banner = new NoDataBannerViewModel<GroupViewModel<object>>(value, AppResources.NoDataToShow);
OnPropertyChanged(nameof(Collection));
}
}
Specified argument was out of the range of valid values. Parameter
name: index
Stacktrace from Xamarin:
at Xamarin.Forms.ListProxy.get_Item (System.Int32 index) [0x0000b] in D:\agent_work\1\s\Xamarin.Forms.Core\ListProxy.cs:127
at Xamarin.Forms.ListProxy.System.Collections.IList.get_Item (System.Int32 index) [0x00000] in D:\agent_work\1\s\Xamarin.Forms.Core\ListProxy.cs:444
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].get_Item (System.Int32 index) [0x00008] in <afec569c85894ae9a18371a2fecd2d37>:0
at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.HeaderViewDisplayingEnded (UIKit.UITableView tableView, UIKit.UIView headerView, System.nint section) [0x0001f] in <82f6100a289642ae988dc0d85a373bef>:0
at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend(intptr,intptr)
at UIKit.UITableView.ReloadData () [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/UIKit/UITableView.g.cs:792
at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateItems (System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Int32 section, System.Boolean resetWhenGrouped) [0x002b8] in <82f6100a289642ae988dc0d85a373bef>:0
at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <82f6100a289642ae988dc0d85a373bef>:0
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in :0
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].GroupedReset () [0x000b6] in <afec569c85894ae9a18371a2fecd2d37>:0
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].OnCollectionChangedGrouped (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00459] in :0
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Boolean fixWindows) [0x00008] in <afec569c85894ae9a18371a2fecd2d37>:0
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in :0
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].OnItemsSourceChanged (System.Boolean fromGrouping) [0x00069] in <afec569c85894ae9a18371a2fecd2d37>:0
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].BindableOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00020] in :0
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in D:\agent_work\1\s\Xamarin.Forms.Core\BindableObject.cs:146
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\agent_work\1\s\Xamarin.Forms.Core\Element.cs:401
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00107] in D:\agent_work\1\s\Xamarin.Forms.Core\BindableObject.cs:602
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\agent_work\1\s\Xamarin.Forms.Core\BindableObject.cs:399
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in D:\agent_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:172
at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\agent_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:56
at Xamarin.Forms.BindingExpression+BindingExpressionPart.b__47_0 () [0x00000] in D:\agent_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:557
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/Foundation/NSAction.cs:163
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at Tux.iOS.Application.Main (System.String[] args) [0x00001] in /Users/simon/Documents/AimyPlus/EceAdmin/Tux/Tux.iOS/Main.cs:17
> Xamarin.Android
Version: 8.2.0.16 (Visual Studio Community)
Android SDK: /Users/simon/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)
7.1 (API level 25)
8.0 (API level 26)
SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.5
SDK Build Tools Version: 25.0.3
Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
Xamarin Inspector
Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1
Apple Developer Tools
Xcode 9.2 (13772)
Build 9C40b
Xamarin.Mac
Version: 4.2.1.28 (Visual Studio Community)
Xamarin.iOS
Version: 11.9.1.24 (Visual Studio Community)
Hash: f62de472
Branch: xcode9.3
Build date: 2018-03-29 19:30:53-0400
It was an issue of the updated Xamarin.Forms 2.51444934. It happened when doing a groupped listview. In order to solve:
ListView.HasUnevenRows = false;
ListView.IsGroupingEnabled = false;
((ObservableCollection<T>)listView.ItemsSource).Clear();
ListView.HasUnevenRows = true;
ListView.IsGroupingEnabled = true;
Put similar code before replacing new data collection. The problem will be solved.
Adding those lines to listview properties works for me.
IsGroupingEnabled="false"
CachingStrategy="RecycleElement"

Cannot get MvvmCross using storyboards in iOS to work

I am trying to write an MvvmCross app using StoryBoards. I know there are similar questions, but I have followed the solutions and I cannot get it to work. I have referenced one of the solutions I have tried in this question.
I'll explain what I have done from the beginning, hopefully this will help in the diagnosis of my problem
Create a project using the the Universal iOS Single View App in Visual Studio.
I do the standard MvvmCross setup, adding nuget, updating AppDelegate etc.
I get it to compile.
I add a new ViewController to the iPhone storyboard. I call it LogonViewController. I set the Class, Storyboard ID and Restoration ID to LogonViewController. The LogonViewController class is generated. I change it to derive it from MvxViewController
I move the entry arrow from the RootViewController (the view controller on the storyboard when it was initially created) to point to the LogonViewController. I leave the RootViewController on the storyboard
I Change the LogonViewController class to derive from MvxViewController and set the Register attribute to LogonView eg
[Register ("LogonView")]
partial class LogonViewController
I add a label to the LogonViewController just as something to display.
I create a custom container derived from MvxTouchViewsContainers as per the post in
MVVMCross support for Xamarin.iOS Storyboards
The problem is that when the overridden method (shown below) is called in the custom container I get An invalid cast exception as it cannot cast a UIKit.UIViewController to a IMvxTouchView
I also get an arithmetic overflow exception
protected override IMvxTouchView CreateViewOfType(Type viewType, MvxViewModelRequest request)
{
return (IMvxTouchView)UIStoryboard.FromName("MyStoryBoard", null)
.InstantiateViewController(viewType.Name);
}
In the trace log I get the following errors
2015-01-28 18:12:09.833 MyApp[3743:68927] mvx:Diagnostic: 8.61 Setup: LastChance start
[0:] mvx:Diagnostic: 8.61 Setup: LastChance start
[0:]
2015-01-28 18:12:10.247 MyApp[3743:68927] mvx:Diagnostic: 9.05 Setup: Secondary end
[0:] mvx:Diagnostic: 9.05 Setup: Secondary end
[0:]
2015-01-28 18:12:10.647 MyApp[3743:68927] mvx:Diagnostic: 9.43 Showing ViewModel LogonViewModel
[0:] mvx:Diagnostic: 9.43 Showing ViewModel LogonViewModel
[0:]
2015-01-28 18:12:11.049 MyApp[3743:68927] TouchNavigation:Diagnostic: 9.83 Navigate requested
[0:] TouchNavigation:Diagnostic: 9.83 Navigate requested
2015-01-28 18:12:11.254 MyApp[3743:68927] Unknown class LogonViewController in Interface Builder file.
2015-01-28 18:12:23.962 MyApp[3743:68927] -[UIViewController bottomLayoutGuide]: guide not available before the view controller's view is loaded
System.OverflowException: Arithmetic operation resulted in an overflow.
at Mono.Debugging.Soft.SoftDebuggerAdaptor.TargetObjectToObject(EvaluationContext ctx, Object obj)
at Mono.Debugging.Evaluation.ExpressionEvaluator.TargetObjectToExpression(EvaluationContext ctx, Object obj)
at Mono.Debugging.Evaluation.ObjectValueAdaptor.CreateObjectValueImpl(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, Object obj, ObjectValueFlags flags)
at Mono.Debugging.Evaluation.ObjectValueAdaptor.CreateObjectValue(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, Object obj, ObjectValueFlags flags)
System.OverflowException: Arithmetic operation resulted in an overflow.
at Mono.Debugging.Soft.SoftDebuggerAdaptor.TargetObjectToObject(EvaluationContext ctx, Object obj)
at Mono.Debugging.Evaluation.ExpressionEvaluator.TargetObjectToExpression(EvaluationContext ctx, Object obj)
at Mono.Debugging.Evaluation.ObjectValueAdaptor.CreateObjectValueImpl(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, Object obj, ObjectValueFlags flags)
at Mono.Debugging.Evaluation.ObjectValueAdaptor.CreateObjectValue(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, Object obj, ObjectValueFlags flags)
System.OverflowException: Arithmetic operation resulted in an overflow.
at Mono.Debugging.Soft.SoftDebuggerAdaptor.TargetObjectToObject(EvaluationContext ctx, Object obj)
at Mono.Debugging.Evaluation.ExpressionEvaluator.TargetObjectToExpression(EvaluationContext ctx, Object obj)
at Mono.Debugging.Evaluation.ObjectValueAdaptor.CreateObjectValueImpl(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, Object obj, ObjectValueFlags flags)
at Mono.Debugging.Evaluation.ObjectValueAdaptor.CreateObjectValue(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, Object obj, ObjectValueFlags flags)
Unhandled Exception:
System.InvalidCastException: Unable to cast object of type 'UIKit.UIViewController' to type 'Cirrious.MvvmCross.Touch.Views.IMvxTouchView'.
I'm at a loss to know what I am doing wrong here. Has anyone got any ideas? This is the versions of software installed
MvvmCross 3.5.0
Visual Studio 2012 Update 4,
Xamarin Universal Installer v3.5.0.0
Xamarin Studio 5.7 v5.7.0.661
Xamarin v3.9.236.0
Update
I took EShy's advice and added the controller and named it LogonView, however I still get a problem where the LogonViewModel is not getting contructed. The log is shown below. Any ideas?
2015-01-29 11:31:33.579 MyApp[12631:273902] mvx:Diagnostic:286.77 Message = [Failed to construct and initialize ViewModel for type MyApp.Core.ViewModels.LogonViewModel from locator MvxDefaultViewModelLocator - check InnerException for more information]
[0:] mvx:Diagnostic:286.77 Message = [Failed to construct and initialize ViewModel for type MyApp.Core.ViewModels.LogonViewModel from locator MvxDefaultViewModelLocator - check InnerException for more information]
[0:]
2015-01-29 11:31:33.985 MyApp[12631:273902] mvx:Diagnostic:287.17 Stack Trace = [ at Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request, IMvxBundle savedState, IMvxViewModelLocator viewModelLocator) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request, IMvxBundle savedState) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.LoadViewModel (IMvxTouchView touchView) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Views.MvxViewExtensionMethods.OnViewCreate (IMvxView view, System.Func`1 viewModelLoader) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.OnViewCreate (IMvxTouchView touchView) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerAdapter.HandleViewDidLoadCalled
[0:] mvx:Diagnostic:287.17 Stack Trace = [ at Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request, IMvxBundle savedState, IMvxViewModelLocator viewModelLocator) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request, IMvxBundle savedState) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.LoadViewModel (IMvxTouchView touchView) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Views.MvxViewExtensionMethods.OnViewCreate (IMvxView view, System.Func`1 viewModelLoader) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.OnViewCreate (IMvxTouchView touchView) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerAdapter.HandleViewDidLoadCalled (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) <Module>:invoke_void_object_EventArgs (object,System.EventArgs)
at Cirrious.CrossCore.Core.MvxDelegateExtensionMethods.Raise (System.EventHandler eventHandler, System.Object sender) [0x00000] in <filename unknown>:0
at Cirrious.CrossCore.Touch.Views.MvxEventSourceViewController.ViewDidLoad () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:46
at MyApp.iOS.Application.Main (System.String[] args) [0x00002] in c:\MyApp.iOS\Main.cs:21 ]
(System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) <Module>:invoke_void_object_EventArgs (object,System.EventArgs)
at Cirrious.CrossCore.Core.MvxDelegateExtensionMethods.Raise (System.EventHandler eventHandler, System.Object sender) [0x00000] in <filename unknown>:0
at Cirrious.CrossCore.Touch.Views.MvxEventSourceViewController.ViewDidLoad () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:46
at MyApp.iOS.Application.Main (System.String[] args) [0x00002] in c:\MyApp\
MyApp.iOS\Main.cs:21 ]
[0:]
2015-01-29 11:31:34.393 MyApp[12631:273902] mvx:Diagnostic:287.58 Inner Exception message = [Problem creating viewModel of type LogonViewModel]
[0:] mvx:Diagnostic:287.58 Inner Exception message = [Problem creating viewModel of type LogonViewModel]
You should name your viewcontroller in the storyboard LogonView and not LogonViewController. That's the viewType.Name that MvvmCross is looking for.
The problem was that a service injected into the LogonViewModel used the MvvmCross Messenger plugin. I had not added the plugin via nuget to the project. The exception that informed me of this was an inner exception of an inner exception. I should have dug deeper. Thanks again to you Stuart for this help and MvvmCross goodness in general. Thanks also to EShy for the naming help.

MVVMCross + Xamarin + WCF Data Services 5.6 = Not Implemented Exception?

I'm using WCF Data Services 5.6 in a PCL project with MVVMCross. In the WPF client the following code (in the viewModel) works like a charm (based on the sample found at http://msdn.microsoft.com/en-us/library/dd756367(v=vs.110).aspx):
DataServiceQuery<T> query = this.LoadItemsQuery;
query.BeginExecute((result) =>
{
try
{
DataServiceQuery<T> resultQuery = result.AsyncState as DataServiceQuery<T>;
foreach (T item in resultQuery.EndExecute(result))
{
// Do something here
}
}
catch (Exception ex)
{
PublishException(ex);
}
}
, query);
But in the Android client, "resultQuery.EndExecute(result)" throws the following exception:
System.InvalidOperationException: An error occurred while processing this request. ---> System.NotImplementedException: The requested feature is not implemented.
at System.Net.WebResponse.get_SupportsHeaders () [0x00000] in <filename unknown>:0
at System.Data.Services.Client.HttpWebRequestMessage.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Data.Services.Client.ODataRequestMessageWrapper.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Data.Services.Client.DataServiceContext.GetResponseHelper (System.Data.Services.Client.ODataRequestMessageWrapper request, IAsyncResult asyncResult, Boolean handleWebException) [0x00000] in <filename unknown>:0
at System.Data.Services.Client.DataServiceContext.EndGetResponse (System.Data.Services.Client.ODataRequestMessageWrapper request, IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Data.Services.Client.RequestInfo.EndGetResponse (System.Data.Services.Client.ODataRequestMessageWrapper request, IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Data.Services.Client.QueryResult.AsyncEndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Data.Services.Client.BaseAsyncResult.EndExecute[QueryResult] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Data.Services.Client.QueryResult.EndExecuteQuery[Appointment] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 }
Any ideas? Has someone tested WCF Data Services 5.6 with MonoDroid?
Thanks in advance
https://github.com/mono/mono/blob/master/mcs/class/System/System.Net/WebResponse.cs
You can see from the source code that it is indeed not implemented.
Mono's WCF support is not complete, so using it against WCF Data Services is risky.
If possible, use ASP.NET Web API instead of WCF at server side, and then on client side you get better support via HttpClient.
The bug is in HttpWebResponse.cs,which should add the following:
public override bool SupportsHeaders
{
get
{
return true;
}
}
Should work with the latest release : Mono for Android 4.12.3.I test and found it worked with Microsoft.Data.Service.Client.Portable.dll.

failed to find constructor for type MvxViewModelLoader MvvmCross IOS

I use MvvmCross for develop a CrossPlatform App.
I work on my Mac and I have not errors when I build my solution.
When I run it... I have this error : failed to find constructor for type Cirrious.MvvmCross.ViewModels.MvxViewModelLoader and highlights base.ViewDidLoad();
Code :
public partial class MainView : MvxViewController
{
static bool UserInterfaceIdiomIsPhone {
get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }
}
public MainView ()
: base (UserInterfaceIdiomIsPhone ? "MainView_iPhone" : "MainView_iPad", null)
{
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
}
It's a default code, I just changed super-class (UIViewController to MvxViewController)
Stacktrace :
Failed to find constructor for type Cirrious.MvvmCross.ViewModels.MvxViewModelLoader
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type) [0x00000] in :0
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer+ConstructingResolver.Resolve () [0x00000] in :0
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.InternalTryResolve (System.Type type, ResolveOptions resolveOptions, System.Object& resolved) [0x00000] in :0
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.InternalTryResolve (System.Type type, System.Object& resolved) [0x00000] in :0
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.Resolve (System.Type t) [0x00000] in :0
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.Resolve[IMvxViewModelLoader] () [0x00000] in :0
at Cirrious.CrossCore.Mvx.Resolve[IMvxViewModelLoader] () [0x00000] in :0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.LoadViewModel (IMvxTouchView touchView) [0x00000] in :0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods+<>c_DisplayClass1.b_0 () [0x00000] in :0
at Cirrious.MvvmCross.Views.MvxViewExtensionMethods.OnViewCreate (IMvxView view, System.Func`1 viewModelLoader) [0x00000] in :0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.OnViewCreate (IMvxTouchView touchView) [0x00000] in :0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerAdapter.HandleViewDidLoadCalled (System.Object sender, System.EventArgs e) [0x00000] in :0
at (wrapper delegate-invoke) :invoke_void_this__object_EventArgs (object,System.EventArgs)
at Cirrious.CrossCore.Core.MvxDelegateExtensionMethods.Raise (System.EventHandler eventHandler, System.Object sender) [0x00000] in :0
at Cirrious.CrossCore.Touch.Views.MvxEventSourceViewController.ViewDidLoad () [0x00000] in :0
at TrainingCatalog.Touch.MainView.ViewDidLoad () [0x00002] in /Users/a_masteruser/Projects/DefaultCollection/_git/HapplyTrainingCatalog/TrainingCatalog.Touch/Views/MainView.cs:30
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00008] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pp-UIWindow.g.cs:129
at TrainingCatalog.Touch.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x0003c] in /Users/a_masteruser/Projects/DefaultCollection/_git/HapplyTrainingCatalog/TrainingCatalog.Touch/AppDelegate.cs:21
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pp-UIApplication.cs:38
at TrainingCatalog.Touch.Application.Main (System.String[] args) [0x00008] in /Users/a_masteruser/Projects/DefaultCollection/_git/HapplyTrainingCatalog/TrainingCatalog.Touch/Main.cs:17
Failed to find constructor for type Cirrious.MvvmCross.ViewModels.MvxViewModelLoader
From the stack trace, I'm guessing the line that is failing is: https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross.Touch/Views/MvxViewControllerExtensionMethods.cs#L44
This is looking in IoC for a type which has been registered in setup as:
protected virtual void InitializeViewModelFramework()
{
Mvx.RegisterType<IMvxViewModelLoader, MvxViewModelLoader>();
}
(from https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross/Platform/MvxSetup.cs#L192)
Looking at MvxViewModelLoader, this is defined in: https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross/ViewModels/MvxViewModelLoader.cs - so it should have a default public parameterless constructor added by the compiler...
With this in mind...
I'm guessing that maybe Xamarin is stripping out the constructor from your deployed binaries. This might be because of your linker settings - so please check that you have set the linker to link "SDK only". But if that doesn't help then this might be down to some Xamarin optimisation/feature - so you might need to .
As a simple workaround you could try overriding Setup so that you use:
protected override void InitializeViewModelFramework()
{
Mvx.RegisterSingleton<IMvxViewModelLoader>(() => new MvxViewModelLoader>());
}
However, even if this works, then I'd be worried that the linker might be stripping out other symbols in your app - so this might not be enough... you might need to chase this through with Xamarin.

Objective Sharpie Fails to generate binding

I am trying to create a simple binding to an enterprise library using Objective Sharpie.
It keeps failing with the following message:
Cannot be negative.
Parameter name: length
System.ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in :0
at Sharpie.ObjC.ObjCExtensions.ToGetAccessorSelectorFromSetAccessor (System.String selector) [0x00000] in :0
at Sharpie.ObjC.CodeDomMassager.MassageMethod (Sharpie.CodeDom.TypeDeclaration type, Sharpie.CodeDom.MethodDeclaration method) [0x00000] in :0
at Sharpie.ObjC.CodeDomMassager.MassageTypeMembers[MethodDeclaration] (Sharpie.CodeDom.TypeDeclaration type, System.Action2 massager) [0x00000] in <filename unknown>:0
at Sharpie.ObjC.CodeDomMassager.MassageType (Sharpie.CodeDom.TypeDeclaration type) [0x00000] in <filename unknown>:0
at Sharpie.ObjC.CodeDomMassager.MassageAll () [0x00000] in <filename unknown>:0
at Sharpie.ObjC.Parser.Parse (System.IO.TextWriter sexpWriter, System.Collections.Generic.List1 stderrLines) [0x00000] in :0
at Sharpie.Mac.MainWindowController+c_AnonStorey3.<>m_B (System.Object o) [0x00000] in :0
From other answers I found that there might be a problem with accessors but I don't find
(void)get
or
(void)set
in my code. Help!

Resources