From 8148feb7c2da229f8c62824b0cf0ce8fb9598dc9 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Wed, 6 Sep 2023 09:00:17 +0200 Subject: [PATCH] Updated MimeKit and MimeKitLite (markdown) --- MimeKit-and-MimeKitLite.md | 41 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/MimeKit-and-MimeKitLite.md b/MimeKit-and-MimeKitLite.md index f51cfea..6c3df86 100644 --- a/MimeKit-and-MimeKitLite.md +++ b/MimeKit-and-MimeKitLite.md @@ -1,5 +1,42 @@ +## Info Because WireMock.Net uses [MimeKitLite](https://www.nuget.org/packages/MimeKitLite) for multipart parsing, this can introduce errors when your project uses [MimeKit](https://www.nuget.org/packages/MimeKit): -``` +## Issue +` error CS0433: The type 'MimeMessage' exists in both 'MimeKit, Version=4.1.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814' and 'MimeKitLite, Version=4.1.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814' -``` \ No newline at end of file +` + +## Solution +The only solution for this is to apply the following changes to your project: + +``` xml + + ⭐ + MimeKitAlias + + +``` + +⭐ add an Alias for the MimeKit NuGet + +In your C# code change this: + +``` csharp +extern alias MimeKitAlias; // ⭐ Add this + +namespace MyNamespace +{ + public class MyClass + { + public void MyMethod() + { + var mail = new MimeKitAlias::MimeKit.MimeMessage(); // ⭐ Use this + } + } +} +``` + +The code should build now without getting the error. + +:books: References +- https://github.com/WireMock-Net/WireMock.Net/issues/990 \ No newline at end of file