jstedfast / MimeKit

A .NET MIME creation and parser library with support for S/MIME, PGP, DKIM, TNEF and Unix mbox spools.
http://www.mimekit.net
MIT License
1.79k stars 360 forks source link

ERROR: The type initializer for 'PerTypeValues1' threw an exception. #1050

Closed Shira-DevY closed 2 weeks ago

Shira-DevY commented 2 weeks ago

Describe the bug I wrote code: MimeMessage message = null; using (var stream = System.IO.File.OpenRead(path)) { message = MimeMessage.Load(stream); } On my machine it works But when I closed the project and installed on another computer it fell in line: message = MimeMessage.Load(stream); with the error: ERROR: The type initializer for 'PerTypeValues1' threw an exception. states that the installation was good because later I installed it on another machine and it worked well there again. The common point for the machines it didn't work on was Microsoft 365 I would appreciate your help/advice Thanks

Platform (please complete the following information):

// Add your code snippet here.
MimeMessage message = null;
    using (var stream = System.IO.File.OpenRead(path))
    {
        message = MimeMessage.Load(stream);
    }
jstedfast commented 2 weeks ago

You probably got hit by this: https://stackoverflow.com/questions/78665861/mimemesage-object-throw-exception

Shira-DevY commented 2 weeks ago

The library System.Runtime.CompilerServices.Unsafe is updated in the app.config as it should be. I forgot to mention that the action I'm trying to do is to get .eml file properties (recipient, author, subject, creation date) There are computers on which it works fine for me (these computers do not have Microsoft 365 and the new Outlook is not installed on them) and computers that encounter the above error (and they have 365 and a new Outlook) I would appreciate your assistance. Thanks

jstedfast commented 2 weeks ago

I can't help you with that because I wouldn't have any idea where to start.