MVVM Cross support for Xamarin Studio on a Mac - c#

I have been exploring the use of MVVM Cross on Xamarin Studio on a Mac. I've been going through the tutorials for N+1 days of MvvmCross on YouTube and I've run into a roadblock that hopefully someone else has experienced.
The tutorials use PCLs and VS 2012, but since I'm on a Mac, I have to use Xamarin Studio. I understand PCLs are not support in Xamarin Studio so I've created a base C# project and then linked the libraries to a Xamarin.Android project. I've read quite a few MvvmCross posts including this one but haven't been able to find a solution.
The project builds successfully and appears to deploy to the emulator successfully, but I can not get the app to run on the emulator. The app immediately closes and the only error I receive is the following non-descript message in the Application Output of Xamarin Studio.
[monodroid-gc] GREF GC Threshold: 1800
[mono] Stacktrace:
[mono]
[mono]
[mono] Unhandled Exception:
[mono] System.NullReferenceException: Object reference not set to an instance of an object
[mono] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
I've set multiple breakpoints but cannot get any them to fire, it appears the error is occurring before my code is run. I downloaded the sample code for the project and it ran successfully so I then went line by line to check for errors but with no success (I even replaced my class files with those from the example. I've confirmed that all of the DLLs are correct. I'm using the precompiled libraries from https://github.com/slodge/MvvmCross-Binaries.
I'm really not sure where to go next to determine the cause of this error. Has anyone else experienced this? I know both Xamarin and MvvmCross focus on Visual Studio integration and PC development; is MvvmCross stable enough to use on Xamarin Studio for a Mac? Does anyone know what my error may be, or what to try next?
I know this is a fairly undefined problem but I'm hoping I'm not the only one to experience this. I've tried to be a descriptive as possible but if anyone need more information, please let me know. Thanks.

Has anyone else experienced this?
No-one I've seen.
I know both Xamarin and MvvmCross focus on Visual Studio integration and PC development
This definitely isn't true for Xamarin - in fact (in my opinion) the reverse is true - I think they work 'Xamarin Studio on a Mac' first, with Visual Studio support second.
For MvvmCross, I generally do work Visual Studio first - this is mainly because I need to use Windows project types (Wpf, WindowsPhone, WindowsStore), because I prefer to use PCLs, and because Resharper owns my coding soul.
is MvvmCross stable enough to use on Xamarin Studio for a Mac?
This is too subjective a question for me to answer. I can tell you lots of Mac-people do use it... and that no-one who has tried has then turned around to me and told me that MvvmCross wasn't stable enough.
The situation with Xamarin PCL support is evolving - the current support seems to change a little with every release currently, and there is a big PCL release coming at some point very soon. This is scheduled for any day now - so I definitely cannot claim that the PCL situation is currently stable.
NuGet2.5 support is also changing - see https://github.com/mrward/monodevelop-nuget-addin/issues/13 - I have no idea when this will be fully available or will know about PCLs on the Mac, but at least the effort has started.
Note: If you want to, then you can always work with Xamarin project types and with file linking instead of with PCL project types. Just because MvvmCross uses PCLs internally it doesn't mean you have to.
Does anyone know what my error may be
I've no idea what your error is there - that NullReferenceException isn't the most verbose error :( You might be able to get more trace from logcat? Other than that, Xamarin forums or support might be able to assist.
what to try next?
I've recorded today's N+1 purely on the Mac without Nuget.
This is currently uploading to:
http://slodge.blogspot.co.uk/2013/05/n22-from-basics-on-mac-n1-days-of.html
http://youtu.be/UC2r4mmj3UI
This is a 'warts and all' live demo of me developing a first Android and iOS project using MvvmCross and PCLs on the Mac. Clearly you can see some issues with things like Xamarin Studio intellisense and with Android emulator debugging (note that these debugger/emulator issues are independent of MvvmCross and PCLs!)
I believe this also shows that right now today on the Mac, Xamarin.iOS is much more mvvmcross/pcl friendly than xamarin.android - but that both are possible to use.
Note that for this demo, I use the assemblies from the VS folder in https://github.com/slodge/mvvmCross-binaries/

I have been same problem.
I have solved migrating my code solution to another new project.
There was no problem with PCL and project link assembly.
I don't know why my solution was broken. I suspect something about package namespace that must be consistent in .xaml and project option.

I know this is an old question, but since there is no real answer to the original question about the null reference exception, here is an issue I ran into and resolved that feels quite similar - Xamarin.Forms app will not run on Android device.

Related

Xamarin iOS: cannot use Firebase Core in project (MT0009 error while loading assemblies)

After installing Xamarin.Firebase.iOS.Core, I get this error message when trying to build and deploy to iOS simulator:
Error while loading assemblies: /Users/{mac username}/Library/Caches/Xamarin/mtbs/builds/{app name}/{build id}/bin/iPhoneSimulator/Debug/Firebase.Core.dll
It seems that the assembly
Firebase.Core.dll
is the only thing that is causing issues. This is the only error/ warning message I get back from the compiler. In my references node, all packages seem to be intact and in place.
This problem arose while trying to integrate Firebase into my app and so after creating a separate project and simply downloading the Xamarin.Firebase.iOS.Core package through NuGet (without adding any code), I get the error above. I have looked at a plethora of similar issues but none of which have fixed my problem. I am now wondering if it is an issue with the package itself but it seems that I am the only one lucky enough to encounter this error. If anyone has any clue as to what might be happening please help! I am new to Xamarin and know little about c-sharp build processes, but evidently need to start learning more about said processes, so any information is useful!
Note: I am using Xamarin Forms but this seems like a platform-specific error since it is coming from the remote iMac.
Not sure what happened, but by some miracle or by accidental causes the problem went away. It could be that I uninstalled Firebase for the indefinite number of times that I did, then installed a much older version of the iOS.Auth Package (which installed the appropriate iOS.Core package). Seeing that building went through perfectly, I kept increasing the version of the package until I got the most recent and is surprisingly (and frustratingly) working as nothing happened. To anyone else who runs into this problem, may I suggest purging your packages and temporary Mac files? But I'm still not sure what I did correctly.

M2Mqtt android/xamarin for some reason not working anymore

I built an xamarin cross platform mobile application last summer. We were waiting for the hardware to be ready for us to deploy the app.
Now everything is ready I kept a copy of the application on my one drive.
I copied the application from my one drive onto my development machine last week I have been working with it in debug mode.
Yesterday I tried to compile in release mode and all of a sudden my
using uPLibrary.Networking.M2Mqtt;
using uPLibrary.Networking.M2Mqtt.Messages;
grayed out and show error could not be found. Now I can't get anything to work the way it did even in debug mode all my mqtt commands are showing an error.
I tried reinstalling the nuget packages but I get error tying to compile to ......... not available in package see author
I just don't understand what happend and why
Please let me know if you have any ideas, from what I've read it may be because I moved the project from a different folder. Please help
You need M2Mqtt for .Net MQTT with uPLibrary. M2Mqtt will provide M2Mqtt.dll to support uPLibrary. You need to add M2Mqtt.dll reference in your project.
Please check M2Mqtt for .Net : MQTT client for Internet of Things & M2M communication.
What I did originally was find m2mqtt.mono.dll which worked fine for a while until I found some bugs that were fixed in more resent commits.
I have now gotten my hands on M2Mqtt.Net.dll which I just added to my Xamarin project and it seems to be working good.
I went to paho.mqtt.m2mqtt master. Downloaded git opened sln in Visual Studio 2017, built solution and got M2Mqtt.Net.dll from M2Mqtt/obj/debug folder and added reference to it in my project.
I'll keep you advised if I have any problems

Xamarin Forms - Plugins.BLE - MvvmCross.Plugins.BLE

I want to develop an app with Xamarin Forms which detects devices and interacts with them by bluetooth connection.
The plugin "Plugins.BLE" seems good to me for my request. I found this plugin here : https://github.com/xabre/xamarin-bluetooth-le
I did not find the plugin "Plugins.BLE" when I wanted to install it in Xamarin Studio, so I tried to use the MvvmCross.Plugins.BLE plugin. So I downloaded it and installed it in my project. A reference to MvvmCross.Platform has been installed in the same time. I set the permissions for bluetooth in the AndroidManifest.xml.
I have many problems with this plugin. In the first place, I initialized an adapter like this :
var adapter = Mvx.Resolve<IAdapter>();
I put this code in my App.xaml.cs but I got a NullReferenceException when I build.
Otherwise, when I put
var ble = Mvx.Resolve<IBluetoothLE>();
Xamarin Studio does not recognize the IBluetoothLE interface.
Maybe errors come from MvvmCross using. I don't want to use MvvmCross so if the plugin "Plugin.BLE" is available I would like to use it but I did not find it.
You have to search for pre release. Currently we haven't released a "stable" 1.0 without the "-beta" postfix. Every package thats version have "-foo" postix are recognized as prerelease by nuget.
The null reference exception is a typical error if you haven't referenced the platform specific package in your iOS or Android app. Running the package on a simulator can cause some problems, too. We are working on this.

Netoffice Hello World

I used VSTO a couple of years ago with Visual Studio to do some nice little addins for outlook. But I can't justify the cost of VS to do some part time projects. As a result I have installed the free version of VS and downloaded a promising office addin tool called NetOffice.
I am ok at c# but can't find a hello world example that includes setting up the environment to work.
I have VS express installed but don't know what to do with the NetOffice assemblies etc to get a simple example working.
I looked through the documentation and found a reference to "Netoffice Developer Toolbox" which set up projects for people who are not using the full version of VS. That sounded like exactly what I was after so I downloaded that also.
When I run the app NetOffice.DeveloperToolbox.exe I get a lot of errors, it does eventually load but tabs are missing and nothing seems to work.
Start up error is:
An attempt was made to load an assembly from a network location which
would have caused the assembly to be sandboxed in previous versions of
the .NET Framework. This release of the .NET Framework does not enable
CAS policy by default, so this load may be dangerous. If this load is
not intended to sandbox the assembly, please enable the
loadFromRemoteSources switch. See
http://go.microsoft.com/fwlink/?LinkId=155569 for more information. |
NotSupportedException | Void .ctor()
Following the link in the error message takes you to a page that has this description:
If you were directed to this topic because of an error message in the
Visual Studio project error list or a build error, see How to: Use an
Assembly from the Web in Visual Studio.
I didn't know i was referencing anything in the web so don't know what to do next.
Can anyone tell me what I need to do to get NetOffice working or if they have found/written a tutorial to getting it sorted IE a hello world tutorial?
Thanks in advance for your help.
you try to start a .net assembly from a network location.
this is forbidden from net policies(normaly)
move the toolbox folder to your hd and everything is okay.
NetOffice contains examples/tutorials for each office product in the release package. you find a lot of example online too directly from the main page(netoffice.codeplex.com) anyway, NetOffice is a 1:1 wrapper, this means if you already know the office object model from VBA or PIA(VSTO), you are ready to use NetOffice(you can use existing PIA code in NetOffice).

AndroidManifest.xml does not merge activity info upon Build

Pretty new to Mono for Android (C#), and I'm seeming to have trouble during one of their tutorials where it mentions that info on Activities is merged into AndroidManifest.xml upon compilation.
The FirstActivity class is set to Compile upon Build, yet no AndroidManifest file is created. One can be created via the Project menu but it doesn't include any information on Activities and does not update when these are changed.
Had a look around on the internet but I only managed to find issues relating to Visual Studio.
Any help would be appreciated! :) Thanks.
edit: I'm using the evaluation version right now, if that's any problem.
edit: Getting more problems it seems. Had trouble accessing the AVD through Mono and decided to reinstall the Android SDK to the latest version. Attempts to run the program on the emulator cause the 'Devices' list to disappear shortly after emulator startup (or, at the very best, it fails to acknowledge that an emulator is active). running 'adb devices' spits out the correct emulator "emulator-5554" or something, but Mono's just repeatedly failing to notice.
It's correctly pointed to Android SDK and Java as far as I know.
The AndroidManifest.xml that is generated is created in:
obj\Debug\android\AndroidManifest.xml
The one in your project is not touched.

Categories