Invalid Cast Exception on .NET Compact Framework

I have a project that I’ve developed for a .NET Compact Framework device using the RemObjects SDK. The server runs on a .NET CF device, and there are two client applications: one to run on a Windows 7 PC and one to run on another .NET CF device.

The service has some methods that return standard types and methods that return a struct. Everything works exactly as expected on the Windows 7 PC client. However, if I call a method that returns a struct from the .NET CF client it throws an “Invalid Cast” exception. Methods that return standard types - string, int, bool, etc. - work properly from the .NET CF client.

The SDK version is 6.0.55.957

Any advice would be appreciated!

Hello Brian.

You need to manually register assemblies containing received complex type(s) on client application startup using the next code:

RemObjects.SDK.TypeManager.TypeAssemblies.Add(typeof(SpecifiedStruct).Assembly);

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

Hope this helps.