Redth/APNS-Sharp — Issue #32: Error "A type load exception has occurred."
Author: C0chett0
Created: 2012-02-14 12:23:28+00:00
State: open

Hi there,

great job with this library. I'm all new to C# but you make it easy for us to use it.

I actually have a single problem. I've built the entire solution (libraries+test programms) at once but when I want to try and send a Push Notification to my device I keep getting a type load exception error.

Logs say i'm correctly connected to the apple sandbox gateway but immediately I see the error appear. After a little debugging, it seems the problem appears when instantiating NotificationPayload.

In a step by step debugging I see NotificationAlert being instantiated smoothly inside the NotificationPayload constructor, but when the focus come back to the Notification constructor, Payload is said to be "A type load exception has occurred." according to the debugger. Then the Notification object appears the same, still in the debugger.

From my research on the Internet this could come from the version of Newtonsoft.Json.Compact.dll but I have no idea what to do with this piece of information.

For information I'm using MonoDevelop 2.8.6.4 on OSX 10.7.2 but I can see the same error running my compiled test on my CentOS server.

And for more information the application message (changed ex.Message to ex.ToString() in the test program to get a full error) :

Notification Queued!
Sleeping 15000 milliseconds before next Notification...
Connecting...
Connected...
Error: System.TypeLoadException: A type load exception has occurred.
at JdSoft.Apple.Apns.Notifications.Notification.ToBytes () [0x0006c] in /Users/laurent/Downloads/Redth-APNS-Sharp-595275f 2/JdSoft.Apple.Apns.Notifications/Notification.cs:90
at JdSoft.Apple.Apns.Notifications.NotificationChannel.Send (JdSoft.Apple.Apns.Notifications.Notification notification) [0x00000] in /Users/laurent/Downloads/Redth-APNS-Sharp-595275f 2/JdSoft.Apple.Apns.Notifications/NotificationChannel.cs:371
at JdSoft.Apple.Apns.Notifications.NotificationConnection.workerMethod () [0x00035] in /Users/laurent/Downloads/Redth-APNS-Sharp-595275f 2/JdSoft.Apple.Apns.Notifications/NotificationConnection.cs:381

I send an SOS to all mono guru around.

Have a good day and thanks in advance for your time.

Laurent