I'm working on a mail service and I can't seem to reference System.Net.Mail or MailKit. I'm left with this error trying download a nuget package for my PCL project reference. What seems to be the alternative way to fix this? I was advised to use Office365 outlook services but I dont know how to use it?
Could not install package 'Mail.dll 3.0.16292.1158'. You are trying to
install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile7', but the package does not
contain any assembly references or content files that are compatible with
that framework. For more information, contact the package author.
A Portable Class Library or .NETPortable means that the library depends on just a limited set of functionality from the system that it runs on, in order to make it cross platform compatible.
The packages that you tried to install were not built for that (they need more base functionality) and so they can't be used with your project.
If you need to stay PCL compliant then you could try MimeKit - purely based on the fact that their page has a section for 'Portable Class Library'; never used it personally.
Related
I have a C# Desktop application I am developing which is meant to read text from a file and convert it into a JsonDocument. I have installed and referenced the System.Text.Json library developed by Microsoft in order to read from the JSON file.
I am however getting a strange error that requires me to reference classes from the System.Memory namespace, and a particular version to be exact. I am unsure of how to add these references to my project because when I use NuGet Package manager to install System.Memory I am getting conflicts with my current packages.
Project is targetting .NET framework 4.6
How can I go about solving these errors without affecting my other packages?
I want to write that C# code convert-nunit-3-nunit-2-results-xml-file, but despite the added nuget package i'm missing the dll in my project.
I see it in the tool's directory of the package cache, but missing it in my project.
What do i overlook?
My project is at present for .Net Core 2.1. Is my issue therefore related to this: Add support for net standard ?
I'm new to .net and don't understand all the differences so far.
As zivkan explained, the package is a tool. In fact, it's an extension to another tool, the NUnit engine package. The NUnit engine knows how to find and use the extension.
NUnit does not publish a package that is intended for use by your code as a library, because we would then have to support it as a library in addition to it's use as an extension to NUnit.
However, NUnit's MIT license allows you to use the source code, which you can find at https://github.com/nunit/nunit-v2-result-writer
Since the code has not yet been ported to .NET Core, you would have to do that yourself.
You didn't overlook anything. Not all NuGet packages are libraries.
NuGet has conventions on how files must be packed in order to use various features. For example, files in the content or contentFiles get copied into the project directory, or build output, depending if the project using the package uses packages.config, or PackageReference. If the package author wants to give you a library that you can use in your code, they must put the library in the lib directory in the nupkg (technically it could be in ref, but those don't get copied to build/publish output, they're only used at build time). The tools directory is, unsurprisingly, intended for tools packages. It's often used by unit test runners, or in this case, a report generator.
So, since the package puts the dlls in the tools directory, this means the package author intends the package to be a tool to assist you during development, but not as a library for you to use in your code. You could try contacting the package author to see if they have published another package with the same dll, this time in the lib directory, so that you can use it your project.
Otherwise you'll need to find a solution that doesn't rely on NuGet bringing you this dll as a library. One option is to have a packages.config file that extracts the package in a solution packages directory, and then you use a dll reference to the dll. Your build script would then need to first restore the packages.config file before building your project. Another option is to check in the dll into your source control management tool, if the dll's license allows that, and again have a dll reference to it.
I'm using Nito.Async both in a PCL framework library and in client app which uses the library. The PCL lib targets .Net4.5 & SL5, and the client is .Net4.5.
If I don't reference Nito.Async in client app, everything is fine. But if I reference it, when i run the app, an MissingMethodException occurs :
Method not found: 'Microsoft.Runtime.CompilerServices.TaskAwaiter`1<!0> Nito.AsyncEx.AwaitableDisposable`1.GetAwaiter()'
After digging a little more, it seems the problem is msbuild copy the Nito lib from portable-net40 referenced by the PCL lib in the target \bin folder, and then, copy the Nito lib from net45 referenced by the client in the target \bin. So it overwrites the first portable Nito.Async DLL... And when I launch the app, the portable-net40 is replaced by the net45.
The only few options I see are :
Directly include Nito.Async source in my library, but it means loosing the Nuget advantage of having up-to-date libs...
Ask Stephen Cleary to rename his DLL for .Net45 target to something like Nito.AsyncEx.Net45.dll instead of Nito.AsyncEx.dll (and do it for each distinct target), but I doubt it's a perfect solution.
How can I handle this kind of DLL conflict ?
Is there something on the Nuget or MsBuild side already made for this kind of problem ?
The portable version is supposed to be replaced by the net45 version in this case. The MissingMethodException you get means that there's an API compatibility bug in the Nito.AsyncEx package.
Looking at the source code, I'm not sure there's a way to fix this. GetAwaiter() returns a TaskAwaiter<T>, but that type has a different identity (it's in a different namespace) for portable libraries targeting Silverlight or .NET 4. I think this was necessary because the constructor is internal so we had to reimplement the class for the portable async support for platforms that didn't have it already.
The simplest fix for this would be to drop support for any platforms which don't already support async from the PCL. So you could target .NET 4.5, WP8, WP8.1, and Windows 8 store apps.
I'm trying to add MvvmCross-SecureStorage plugin of MvvmCross to PCL wich contains classes shared between Universal Widows app iOs apps and Android apps, but I'm getting this kind of error.
Could not install package 'Beezy.MvvmCross.Plugins.SecureStorage 1.0.0'. You are trying to install this package into a project that targets 'portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Anybody successfully added this plugin to PCL?
Looking at https://github.com/ChristianRuiz/MvvmCross-SecureStorage it looks like this project doesn't yet support the new unified xamarinios10 target which is included in your list.
One route forwards would be to add unified support to that open source project and to send them a Pull Request.
I don't understand this post - http://slodge.blogspot.co.uk/2013/01/almost-portable-binaries.html
I'm still slightly confused. Are you saying that if we choose to use something like Json.Net in our app, we need to use a version specifically for MonoDroid and another specifically for MonoTouch? Currently, I have a Portable Class Library that contains my view models. My view models rely on Json.
When I attempt to manually add a reference to the NewtonSoft library included with MvvmCross, I get a compile-time error that says: "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)"
If I attempt to add Json.Net via NuGet, I receive an error that says: "Successfully installed 'Newtonsoft.Json 5.0.3'.
Successfully uninstalled 'Newtonsoft.Json 5.0.3'.
Install failed. Rolling back...
Could not install package 'Newtonsoft.Json 5.0.3'. You are trying to install this package into a project that targets 'portable-win+net45+MonoAndroid16+sl40+net10+wp71', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."
What is going on?
The situation with PCLs inside the xamarin products is rapidly evolving - proper pcl support should be available within a few weeks, and there are also big mono2->mono3 changes occurring.
Until these changes are a bit more complete, the situation is:
you will probably be able to use existing profile 2 and profile 104 PCLs on droid as binaries
you may get away with using PCL binaries on iOS - but it's less likely
it is safest to rebuild your PCLs for each platform
Specifically for json.net I have bundled a version with mvx for several months and not had a problem on iOS or touch, but I have not used every option and code path - so there may be gremlins lurking in this approach.
For nuget support for droid and touch, dsplaisted added this to nuget 2.5 (a hero!) - but so far the only package author i know who has added support for xamarin nuget targets is me - please do encourage other authors to join in - maybe by sending them a pull request?