{"action":"created","issue":{"url":"https://api.github.com/repos/dmcgiv/DKIM.Net/issues/8","labels_url":"https://api.github.com/repos/dmcgiv/DKIM.Net/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/dmcgiv/DKIM.Net/issues/8/comments","events_url":"https://api.github.com/repos/dmcgiv/DKIM.Net/issues/8/events","html_url":"https://github.com/dmcgiv/DKIM.Net/issues/8","id":65284811,"number":8,"title":"Exception on DKIM.MailMessageExtensions.DkimSign","user":{"login":"isendrak","id":11725621,"avatar_url":"https://avatars.githubusercontent.com/u/11725621?v=3","gravatar_id":"","url":"https://api.github.com/users/isendrak","html_url":"https://github.com/isendrak","followers_url":"https://api.github.com/users/isendrak/followers","following_url":"https://api.github.com/users/isendrak/following{/other_user}","gists_url":"https://api.github.com/users/isendrak/gists{/gist_id}","starred_url":"https://api.github.com/users/isendrak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isendrak/subscriptions","organizations_url":"https://api.github.com/users/isendrak/orgs","repos_url":"https://api.github.com/users/isendrak/repos","events_url":"https://api.github.com/users/isendrak/events{/privacy}","received_events_url":"https://api.github.com/users/isendrak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-30T19:36:22Z","updated_at":"2015-06-09T18:24:08Z","closed_at":null,"body":"Hi there,\r\nfound this really promising project, after almost smashing my keyboard against the next wall, while searching for a way to DKIM-Sign emails in C#.\r\nCompiling works perfectly (not a single warning/error), but when i try to execute even a simple program, like the example one from the readme, it gives me an exception when calling the DkimSign-method.\r\nHere's, what it says:\r\n```\r\nUnhandled Exception:\r\nSystem.TypeInitializationException: An exception was thrown by the type initializer for DKIM.MailMessageText ---> System.NullReferenceException: Object reference not set to an instance of an object\r\n  at DKIM.MailMessageText..cctor () [0x00000] in <filename unknown>:0 \r\n  --- End of inner exception stack trace ---\r\n  at DKIM.MailMessageExtensions.DkimSign (System.Net.Mail.MailMessage message, DKIM.DkimSigner signer) [0x00000] in <filename unknown>:0 \r\n  at Sendmail.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 \r\n[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for DKIM.MailMessageText ---> System.NullReferenceException: Object reference not set to an instance of an object\r\n  at DKIM.MailMessageText..cctor () [0x00000] in <filename unknown>:0 \r\n  --- End of inner exception stack trace ---\r\n  at DKIM.MailMessageExtensions.DkimSign (System.Net.Mail.MailMessage message, DKIM.DkimSigner signer) [0x00000] in <filename unknown>:0 \r\n  at Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 \r\n```\r\nAny idea?\r\nP.S.: Here's an example of where exactly the exception occurs:\r\n```\r\nusing System.Net.Mail;\r\nusing DKIM;\r\nstatic class Program{\r\n\tpublic static void Main(string[] args){\r\n\t\tMailMessage mail = new MailMessage();\r\n\t\tmail.From = new MailAddress(\"sender@domain.org\");\r\n\t\tmail.To.Add(new MailAddress(\"receiver@another-domain.com\"));\r\n\t\tmail.Subject=\"DKIM.Net Test\";\r\n\t\tmail.Body=\"Some stuff about stuff and such...\";\r\n\t\tIPrivateKeySigner pks = PrivateKeySigner.Create(@\"-----BEGIN RSA PRIVATE KEY-----\r\n<The private key goes here>\r\n-----END RSA PRIVATE KEY-----\r\n\");\r\n\t\tDkimSigner dkim = new DkimSigner(pks, \"domain.org\", \"dkim\", new string[] { \"From\", \"To\", \"Subject\" });\r\n\t\tmail.DkimSign(dkim); //And here the exception goes off...\r\n\t}\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/dmcgiv/DKIM.Net/issues/comments/110454976","html_url":"https://github.com/dmcgiv/DKIM.Net/issues/8#issuecomment-110454976","issue_url":"https://api.github.com/repos/dmcgiv/DKIM.Net/issues/8","id":110454976,"user":{"login":"jstedfast","id":338984,"avatar_url":"https://avatars.githubusercontent.com/u/338984?v=3","gravatar_id":"","url":"https://api.github.com/users/jstedfast","html_url":"https://github.com/jstedfast","followers_url":"https://api.github.com/users/jstedfast/followers","following_url":"https://api.github.com/users/jstedfast/following{/other_user}","gists_url":"https://api.github.com/users/jstedfast/gists{/gist_id}","starred_url":"https://api.github.com/users/jstedfast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jstedfast/subscriptions","organizations_url":"https://api.github.com/users/jstedfast/orgs","repos_url":"https://api.github.com/users/jstedfast/repos","events_url":"https://api.github.com/users/jstedfast/events{/privacy}","received_events_url":"https://api.github.com/users/jstedfast/received_events","type":"User","site_admin":false},"created_at":"2015-06-09T18:24:08Z","updated_at":"2015-06-09T18:24:08Z","body":"It looks like the MailMessageText static constructor is failing due to a null reference somewhere.\r\n\r\nMy guess is that since MailMessageText relies heavily on reflecting various non-public types from the BCL, that this is the problem.\r\n\r\nI've just added support for DKIM signatures to [MimeKit](https://github.com/jstedfast/MimeKit) that you can use instead which does not rely on any non-public BCL classes because I've implemented my own MIME parser and serializer.\r\n\r\nSince you'll probably need to send the message via SMTP, you'll probably also want to take a look at [MailKit](https://github.com/jstedfast/MailKit).\r\n\r\nHopefully Damien doesn't mind me making this suggestion."}}