Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using mimekit nuget package (via paket) in common project removes existing System.net.http.dll from other projects referencing common project #482

Closed
amitpanwarIndia opened this issue May 2, 2019 · 11 comments

Comments

@amitpanwarIndia
Copy link

Describe the bug
Mimekit used in common project is removing System.net.http used in dependent project.

Expected behavior
System.net.http.dll should be present in dependent project.

Desktop (please complete the following information):

  • OS: Window 10

Additional context
I had added a new reference of mimekit library (added mimekit and mailkit via paket) in common project used by several other projects.

To use mimekit I used below code:

using MimeKit;
namespace Project.Common.Email.Interfaces
{ public interface IMailKitBody
{ BodyBuilder BodyBuilder
{ get; set; }
} }

But while building the complete solution after adding above file, System.net.http.dll is getting removed from one of the dependent projects having reference of common project and another project which actually have a reference of System.net.http.dll.

And as soon as I remove this file from Common then System.net.http.dll starts appearing in the dependent project.

Could anyone help me out how this problem be resolved?

I know Mimekit is dependent upon System.net.http.dll and it could conflict with existing one in dependent projects. I have already tried following things:
-removing System.net.http.dll reference from common
-Setting Copy Local property of DLL to True
-Adding reference System.net.http.dll from package folder

@jstedfast
Copy link
Owner

  1. What Framework version does your project use?
  2. What version of System.Net.Http does your project use? Is it newer or older than the one MimeKit requires?

@jstedfast
Copy link
Owner

Might just be a bug in paket (I don't even know what that is).

@amitpanwarIndia
Copy link
Author

paket is an alternative to download nuget packages.
My project is using 4.7.1 version.
Project is referencing System.Net.Http from two places, some places at C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.1\ (version 4.0.0.0) and C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\ (version 4.2.0.0)

Later one is the latest Dll from Microsoft . I don't find Mimekit using System.net.http version 4.3.0 anywhere.

@jstedfast
Copy link
Owner

What's your proposed solution?

@jstedfast
Copy link
Owner

You say your project is .NET v4.7, but what framework version of MimeKit is it using? Is it using the .NET v4.5 version? Or the .NETStandard 2.0 version?

Maybe if you make it use the net45 version of MimeKit it'll be fine? I don't know.

@jstedfast
Copy link
Owner

Try installing packages from:

https://www.myget.org/feed/mimekit/package/nuget/MimeKit
and
https://www.myget.org/feed/mimekit/package/nuget/MailKit

There is no longer an explicit NuGet dependency on System.Net.Http for the .NETStandard2.0 version. Maybe that will fix it?

@amitpanwarIndia
Copy link
Author

amitpanwarIndia commented May 3, 2019

I used net45 only and when I use mime core DLLs then it's actually copying the required files at the place but then Mime doesn't work and gives exception as below:
"System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'MimeKit.ParserOptions' threw an exception.
Source=MimeKit
StackTrace:
at MimeKit.MimeMessage..ctor()
at MailTest.Program.Main(String[] args) in C:\Users$User$\source\repos\MailTest\MailTest\Program.cs:line 12

Inner Exception 1:
TypeInitializationException: The type initializer for 'MimeKit.Utils.CharsetUtils' threw an exception.

Inner Exception 2:
FileNotFoundException: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

@jstedfast
Copy link
Owner

If you are getting that exception, then you've mixed and matched net45 with netstandard2.0

@amitpanwarIndia
Copy link
Author

I was giving a try to check if that library works for me but appropriately it's not. So currently I am targetting 4.7.1 NET framework and using net45 library where issue is popping up.

@jstedfast
Copy link
Owner

jstedfast commented May 3, 2019

The reason I asked you to try the MyGet packages was because I removed the System.Net.Http nuget references for the netstandard2.0 framework versions of the assemblies.

But if you are referencing the net45 versions of MimeKit and MailKit (btw, you need to be consistent with those 2 libs and use the same framework version of each), then your issue is in your own project and not MimeKit or MailKit for sure.

@jstedfast jstedfast transferred this issue from jstedfast/MailKit May 12, 2019
@jstedfast
Copy link
Owner

Did you ever check the MyGet MimeKit packages to see if they fixed your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants