TypeLoadError in Monotouch

I have created a SDK client in Monotouch (.993). Retrieving simple types like date and string works fine. Now I want to retrieve an array of a struct (which only has simple types), but now I get a TypeLoadException

{System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.   at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)   at System.Reflection.Assembly.GetTypes () [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:357    at RemObjects.SDK.TypeManager.FindType (System.String typeName) [0x00000] in :0    at RemObjects.SDK.TypeManager.CreateInstanceOfType (System.String typeName) [0x00000] in :0    at RemObjects.SDK.BinSerializer.ReadComplex (System.String aName, System.Type aType) [0x00000] in :0    at RemObjects.SDK.Serializer.Read (System.String name, System.Type type, StreamingFormat format) [0x00000] in :0    at RemObjects.SDK.BinSerializer.ReadArray (System.String iName, System.Type iType, StreamingFormat aFormat) [0x00000] in :0    at RemObjects.SDK.Serializer.Read (System.String name, System.Type type, StreamingFormat format) [0x00000] in :0    at RemObjects.SDK.Message.Read (System.String aName, System.Type aType, StreamingFormat aFormat) [0x00000] in :0    at POCtest.ROServer2Service_Proxy.RequestKlanten (System.String aID, POCtest.KlantRec[]& data) [0x0004d] in /Users/hlogmans/Mobile/TestROServer/iOS/ROServer2Library_Intf.cs:218    at POCtest.Testlist.Start () [0x0001e] in /Users/hlogmans/Mobile/TestROServer/iOS/POC-test/Testlist.cs:72    at POCtest.Testlist.m__0 () [0x00000] in /Users/hlogmans/Mobile/TestROServer/iOS/POC-test/Testlist.cs:45    at MonoTouch.Dialog.StringElement.Selected (MonoTouch.Dialog.DialogViewController dvc, MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x0000b] in /Developer/MonoTouch/Source/MonoTouch.Dialog/MonoTouch.Dialog/Elements.cs:689    at MonoTouch.Dialog.DialogViewController.Selected (MonoTouch.Foundation.NSIndexPath indexPath) [0x00029] in /Developer/MonoTouch/Source/MonoTouch.Dialog/MonoTouch.Dialog/DialogViewController.cs:518    at MonoTouch.Dialog.DialogViewController+Source.RowSelected (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00019] in /Developer/MonoTouch/Source/MonoTouch.Dialog/MonoTouch.Dialog/DialogViewController.cs:364    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) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29    at POCtest.Application.Main (System.String[] args) [0x00000] in /Users/hlogmans/Mobile/TestROServer/iOS/POC-test/Main.cs:17 }

In the details there are two lines:
{System.TypeLoadException: Could not load type ‘IpHttpClientRequest’ from assembly ‘RemObjects.SDK.MonoTouch, Version=6.0.57.993, Culture=neutral, PublicKeyToken=null’.}
{System.TypeLoadException: Could not load type ‘RemObjects.SDK.SuperTcpChannelWorker’ from assembly ‘RemObjects.SDK.MonoTouch, Version=6.0.57.993, Culture=neutral, PublicKeyToken=null’.}

I did not recompile the sources, just took the dlls from the mono touch folder from my windows machine. And a few lines earlier the connection works OK.

These are the sources, it failes at the end:

using System;
using System.Collections.Generic;
using System.Linq;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
using RemObjects.SDK;

//using RemObjects.SDK;

namespace POCtest
{
	public partial class Testlist : DialogViewController
	{
		public EntryElement ServerIdElement { get; set; }

		public StringElement ServerTxtElement { get; set; }

		public Section KlantenSection { get; set; }
		
		public WinInetHttpClientChannel channel { get; private set; }

		public BinMessage message { get; private set; }

		public IROServer2Service service { get; private set; }
		
		public Testlist () : base (UITableViewStyle.Grouped, null)
		{
			//TypeManager.TypeAssemblies.Add(typeof(POCtest.Testlist));
			                                    
			channel = new RemObjects.SDK.WinInetHttpClientChannel ();
			channel.TargetUrl = "http://192.168.0.16:9503/bin";
			message = new RemObjects.SDK.BinMessage ();
			service = CoROServer2Service.Create (message, channel);
			
			//service = (new RemObjects.SDK.RemoteService(message, channel, false, )) ;
			//dta.
			DateTime dt = service.GetServerTime ();
			
			
			Root = new RootElement ("Testlist");
			Section se = new Section ("Eerste sectie");
			se.Add (new StringElement ("Start", () => {
				Start (); }));
			ServerIdElement = new EntryElement ("Server ID", "ID", String.Empty);
			se.Add (ServerIdElement);
			ServerTxtElement = new StringElement ("Server txt", "");
			se.Add (ServerTxtElement);
			       
			se.Add (new StringElement ("Serverdate", dt.ToLongTimeString ()));
				
			KlantenSection = new Section ("Klanten");
			
			Root.Add (se);
			Root.Add (KlantenSection);
				
		}

		void Start ()
		{
			ServerIdElement.FetchValue ();
			String resvalue = "";
			if (service.RequestData (ServerIdElement.Value, out resvalue)) {
				// success
				ServerTxtElement.Value = resvalue;
			} else {
				// failure
				ServerTxtElement.Value = resvalue;
			}
			
			KlantRec[] klijst = null;
			KlantenSection.Clear ();
			if (service.RequestKlanten (ServerIdElement.Value, out klijst)) {    /// <<<<<<<<==============
				foreach (KlantRec k in klijst) {
					KlantenSection.Add (new StyledStringElement (k.Naam, k.Adres, UITableViewCellStyle.Subtitle));
					
				}
			}
			
			
			ReloadData ();
			
		}
	}
}

Found the solution: used the standard remobjects.internetpack.dll instead of the remobjects.internetpack.monotouch dll. Took some time to find it, because it;s not below Remobjects folders…

Working like a charm now :slight_smile:

PS: If you try to download it from the site, you get at the regular downloadpage, but under ‘free products’ it is no longer listed.

This page: http://www.remobjects.com/ip.aspx
points to a download location on
http://www.remobjects.com/trials.aspx#free
But it is not listed there anymore. And I really miss a ‘download as zip’ option on code.remobjects.com

Hello

This is really weird because calls using only simple data types use the same IpHttpClientRequest and SuperTcpChannelWorker classes that fail to load a few lines below.

Could you, if possible, send full client project and server’s RODL to support@ so we’ll investigate this issue more deeply?

Thanks in advance

Also, in most cases problems with sending/receiving custom data types on non-full .NET platforms are due to assemblies missed from TypeManager.TypeAssemblies list. See the FAQ at

http://wiki.remobjects.com/wiki/Client_FAQs_(RemObjects_SDK)#Why_do_I_get_an_.27Unknown_class_.27…27_found_in_stream…27_exception_when_a_structure_is_received_from_server_in_non-.NET_platform_.28ie_Compact_Framework.2C_Silverlight.2C_WindowsPhone7.2C_MonoTouch_etc.29_clients.3F

Hi antonk,

I remembered needing to register the types from when I used the .Net version last year, so when I got that error the solution was found easily.

The error is probably not the real base error, because it indeed makes no sense. So probably not registering the type was the primary error, but surfaces as this error. Using the monotouch-dll-version probably helps handling the error better.

The type I created was a simple array of a structure having a few string properties. (array of customers with a name and address).

The real cause of the error was PEBKAC: I copied the monotouch dll’s from C:\Program Files (x86)\RemObjects Software\RemObjects SDK for .NET\Bin. Then noticed there was no monotouch dll for InternetPack (blamed you :slight_smile: ) because there IS a internetpack dll one directory level higher.

So what would have helped me, was a readme.txt or dependencies.txt in the monotouch folder, pointing to the default InternetPack folder, because it’s not under a Remobjects folder. But then, maybe it’s in the docs I didn’t read very well…

You are right, this issue (assembly references etc) needs some clarifications.
So I have logged issue #55236 so installer script for RemObjects SDK will be improved to deploy InternetPack assemblies next to RemObjects SDK assemblies.

Thanks for follow-ups