Xamarin Incompatible target framework error - can NuGet help me? - c#

I am coding a Xamarin application and I wish to add the MonoDroidToolkit as a project to my current solution. I have done this correctly, and my solution builds.
I now need to add a reference in my application to the MonoDroidToolkit project.
I have selected the "Edit References" option in the References folder. I then browse to the projects tab to select the project. The project is listed there, however I cannot select the project because of this description:
com.refractored.monodroidtoolkit (incompatible target framework:
MonoAndroid, Version=v4.2)
Here is an screenshot of the description:
I have changed the target framework of each project to be the same and also to be automatic, however, no matter what target framework I select, I cannot add the reference because of the above description.
I have done a check on the Mono.Android reference in each of my projects. In my current project, the description is version 4.1 Support and the MonoDroidToolkit is version 4.2 support.
Is this that the problem is? How can I easily update the 4.1 Support reference to be the latest? Can I get NuGet to do this, or is there another way to update all my references?

In the same solution an Android project can only reference another project if its target framework is the same version or a lower version.
You can change your project's target framework version by right clicking the project in the Solution window, selecting Options, then selecting Build - General. At the top is the Target Framework for that project. If you change that to Android 4.2 (Jelly Bean) then you should be able to reference the MonoDroidToolkit project.
The simplest way to use MonoDroidToolkit is to install it from NuGet.

Open Xamarin Studio and click check for updates. This should update your Monodroid Version

Related

Error CS1703 Multiple assemblies with equivalent identity have been imported while building the Enterprise Bot Framework project

I got the below error while building the Enterprise Bot Template Project in VS2017. Not sure what i 'm doing wrong here.
Severity Code Description Project File Line Suppression State
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Users\XXX.nuget\packages\microsoft.netcore.app\2.1.0\ref\netcoreapp2.1\System.Runtime.Serialization.Json.dll' and 'C:\Users\XXX.nuget\packages\system.runtime.serialization.json\4.3.0\ref\netstandard1.0\System.Runtime.Serialization.Json.dll'. Remove one of the duplicate references. SovereignBot C:\Users\XXX\Documents\Visual Studio 2017\Projects\SovereignBot\SovereignBot\CSC 1 Active
Any ideas how to fix?
I'm not able to replicate this issue with a fresh install of the Enterprise VSIX template. This leads me to believe the issue is either in your code or on your machine.
After researching, it appears there could be a couple of problems and solutions:
Your Local/Development and Build servers use different versions of Visual Studio
Update Visual Studio for both environments
If you're still experiencing issues, try installing the Microsoft.CodeDom.Providers.DotNetcompilerPlatform NuGet package.
NuGet or .NET Core is out of date
Update NuGet
Update the appropriate .NET Core SDK. Currently, Bot Framework is supported well on .NET Core 2.2. Keep in mind that if you have 2.2 installed, you may need to update to the latest sub-version (v2.2.104, as of now). Keep in mind you may also need to upgrade your NuGet packages within the project in order to be compatible to the .NET Core SDK.
Ensure your bot is using the correct .NET Core Target Framework by right-clicking the Project > Properties > Application:
Your Visual Studio version doesn't handle dependency version collisions on its own
Update your Visual Studio
You have a duplicate reference to the same package (but possibly different versions) in your .csproj file
This is more likely if you're using code brought in from another project.
Delete or comment out the duplicate by right-clicking on your Project in Visual Studio, and clicking Edit .csproj:
You have a package installed via both NuGet and locally
(I don't believe this is the issue for you, since both of your packages appear to be in the NuGet directory)
Go to the file path of one of the dependencies and delete it.

.NET reference not available in my project (Class Library). Getting compiler error "mismatch between processor architecture"

I have a Class Library which needs the .NET reference to work as it utilizes a lot of System APIs but I am unable to add the reference from the Add References dialogue box. The .NET reference isn't available under Assemblies in the Reference Manager.
This is how my project looks like and I get the following error when I build this project:
There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\\mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
Following is the screenshot of my Reference Manager
I want the .NET reference as attached to the image below.Any idea how can I solve this issue? Thanks in advance :)
Found the answer to this question.
To resolve the process architecture mismatch issue, I followed the following steps :
First I uninstalled the nuget packages in my project.
Then I opened the properties of my project. Left-click your project and open Properties.
Click on Library in the left panel and under Targets click Change. If the .NET Framework is checked, uncheck it and save by clicking Ok.
Then re-install the nuget packages and build again. It worked like a charm. It seems that Visual Studio 2017 automatically adds the .NET reference. I believe its a bug in VS 2017
To add one of the many .NET libraries, right-click on "References" and select "Add Reference".
The dialog that opens up has a menu on the left, and the .NET libraries can be found under "Assemblies" -> "Framework".
For example, System.Web.Services. (There is no ".NET reference" per se... it is divided into many assemblies).

Could not install package - Package target the same as project's settings

I'm working on an Android project in Xamarin for Visual Studio.
I'm getting an error whereby the Xamarin.Facebook.Android SDK targets the 5.1 framework, which is what my
Target Framework(Compile using), Target Android version and Minimum Android version are all set to(Have tried different variants of higher and lower).
The package in question has a dependency of Android V7, which I have installed.
Have an added an image for good measure.
This is a fresh project, and i've tried rebuilding the solution after any trial-and-error changes to the project's properties.
Screenshot: https://ibb.co/jOtfKk
Is this a bug, or has someone else encountered this scenario?
Created another project and it miraculously worked this time.
Man I hate the VS, C# and Xamarin world.

Unable to install System.Net.Http in Xamarin portable project

Hello I'm new to Xamarin,
I'm trying to install the System.Net.Http to a Xamarin portable project using NuGet Package Manager.
However, whenever I try to download it I get this error
Could not install package 'System.Net.Http 4.3.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', 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
I tried every possible version of the package with no use. Could anybody provide some assistance?
Actually the way I managed to solve this problem was weird
I found a referenced assembly called
.NET --> right click View in object browser --> select System.Net.Http --> clicked add reference to the selected project
and the reference is added
Have you tried to install Microsoft.Net.Http? I use it in my PCL Xamarin Forms apps.
This can be resolved by changing the profile number for the PCL project.
Personally, i would untick all the unneeded target frameworks by going to: Project Options -> Build - General - Change Targets.
In my case i have unticked Windows Phone silverlight 8 and the profile number got changed from PCL 4.5 Profile 259 to PCL 4.5 Profile 111 as shown in this screenshot:
After doing so System.Net.Http can be added easily.

Where can I find the assembly System.Web.Extensions dll?

I'm messing around with some JSON and I'm trying to use the JavascriptSeralizer Class but I cannot for the love of god find a link to find where to add the assembly to my project. Someone help please!
Update
I'm using .NET 4.0 and its not in the .Net tab when you right click on references -> add reference in the solution explorer of Visual C# 2010.
I had this problem myself. Most of the information I could find online was related to people having this problem with an ASP.NET web application. I was creating a Win Forms stand alone app so most of the advice wasn't helpful for me.
Turns out that the problem was that my project was set to use the ".NET 4 Framework Client Profile" as the target framework and the System.Web.Extensions reference was not in the list for adding. I changed the target to ".NET 4 Framework" and then the reference was available by the normal methods.
Here is what worked for me step by step:
Right Click you project Select Properties
Change your Target Framework to ".NET Framework 4"
Do whatever you need to do to save the changes and close the preferences tab
Right click on the References item in your Solution Explorer
Choose Add Reference...
In the .NET tab, scroll down to System.Web.Extensions and add it.
EDIT:
The info below is only applicable to VS2008 and the 3.5 framework. VS2010 has a new registry location. Further details can be found on MSDN: How to Add or Remove References in Visual Studio.
ORIGINAL
It should be listed in the .NET tab of the Add Reference dialog. Assemblies that appear there have paths in registry keys under:
HKLM\Software\Microsoft\.NETFramework\AssemblyFolders\
I have a key there named Microsoft .NET Framework 3.5 Reference Assemblies with a string value of:
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\
Navigating there I can see the actual System.Web.Extensions dll.
EDIT:
I found my .NET 4.0 version in:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.Extensions.dll
I'm running Win 7 64 bit, so if you're on a 32 bit OS drop the (x86).
The assembly was introduced with .NET 3.5 and is in the GAC.
Simply add a .NET reference to your project.
Project -> Right Click References -> Select .NET tab -> System.Web.Extensions
If it is not there, you need to install .NET 3.5 or 4.0.
Your project is mostly likely targetting .NET Framework 4 Client Profile. Check the application tab in your project properties.
This question has a good answer on the different versions: Target framework, what does ".NET Framework ... Client Profile" mean?
I had this issue when converting an older project to use a new version of Visual Studio. Upon conversion, the project target framework was set to 2.0
I was able to solve this issue by changing the target framework to be 3.5.

Categories