I downloaded Xamarin Studio to build my first application, but I'm having some problems which I have not found a solution.
First of all I have created a new solution with the App Xamarin.Forms Blank template. When I have tried to build it, a few errors have appeared (I did not changed a single line from the template):
The type or namespace name 'Xamarin' could not be found (are you mission a using directive or an assembly reference?)
The type or namespace name 'Application' could not be found (are you mission a using directive or an assembly reference?)
Then I supposed that the Xamarin.Forms package was missing, so I clicked on Project > Add NuGet Packages... and I tried to install the Xamarin.Forms package. Here is where I get stuck, because a new error is displayed:
Could not install package 'Xamarin.Forms 1.3.3.6323'. You are trying to install this package into a project that targets 'portable-Profile78', 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 would appreciate any help, because I have not found any solution.
The error message suggests that you do not have the Portable Class Libraries (PCLs) installed.
If you are on the Mac you can get these installed by installing the Mono Development Kit (MDK).
If you are on Windows the procedure is a bit more tricky. To install the Portable Class Libraries on Windows you have three options:
Install Visual Studio 2013 (full or Express version). Update 2 or above is required.
Install the Portable Library Tools and the Portable Library Reference Assemblies 4.6.
Install the Portable Library Tools and copy the .NETPortable directory from Mono over to Windows.
One problem with 2. is that installing the Portable Library Reference Assemblies 4.6 does not install them into the correct location but instead just installs a PortableReferenceAssemblies.zip file into the directory:
C:\Program Files (x86)\Microsoft .NET Portable Library Reference Assemblies 4.6
This PortableReferenceAssemblies.zip file contains three directories (4.0, 4.5 and 4.6) which need to be extracted and copied into the PCLs directory:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable
There is more detail in the Installing Portable Class Libraries for Xamarin Studio post but the above should give you an overview of what is required.
Related
I am trying to install EMGU using Nuget. I am using Framework 4.8. WinForms. I'm able to install Emgu.CV but when I try installing Emgu.CV.runtime.windows I get an error saying:
"Could not install package 'Emgu.runtime.windows.msvc.rt.x64 19.28.29336'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.8', 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.
One solution on stackoverflow (Emgu error when trying to install emgu.CV.runtime.windows in VC# 2017) says that "the solution is migrating from package.config to package references" but it didn't work in my case. When I changed migrating I get an error when installing Emgu.CV too. The error is "Unable to find fallback package folder 'C:\Microsoft\Xamarin\NuGet'."
After these I tried manually installing Emgu.runtime and copying dll files but I got a problem related to cvextern.dll. It says that the file is not accessible. I tried registering it rgsvr32 it didn't work. So working manually didn't help either.
How am I supposed to install EMGU.
.netFramework version is not compatible with the package that you are trying to install.
1-Uninstall the packages completely from your project. 2-downgrade
your project's .netFramework version from Properties of the project
3-Reinstall the packages.
I installed some ASP.NET packages (FirebaseStorage.net if it matters) via Nuget in my game's project in Visual Studio.
Visual Studio itself shows no errors, as it probably understands using Firebase.Storage internally, but when it comes to Unity, it says
The type or namespace name 'Firebase' could not be found (are you missing a using directive or an assembly reference?)
I believe this happens because I installed this package through the Nuget Package Manager, inside Visual Studio, and it probably has nothing to do with Unity, so Unity doesn't find it.
How can I make Unity understand packages from Nuget?
If you want to use a Nuget package in Unity you have to add it manually.
How you can do this:
create a separate temporary Visual Studio project
install the Nuget package
copy the dll's from the temporary project to a "plugins" folder in the Assets folder of Unity.
Unity now builds the project with the dll's of the Nuget package
However, now comes the hard part of having to do it manually: if the dll has dependencies on other dll's, these will also have to be added manually. That is the big advantage of Nuget package manager.
When trying to install the netmq vis nuget, I get the following error:
Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
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.
The problem is that netmq depends on AsyncIO. when installing it, nuget find that the assembly is not compatible with .Net 4.5.
so nuget fail in installing AsyncIO, and then failed in installing netmq.
So I downloaded the AsyncIO Source from Github and build it locally with .Net 4.5.
After that and added the dll of AsyncIO built locally as a reference for my project.
Theoretically, NetMQ should be successfully installed with nuget. because I added the needed reference to AsyncIO.
But when trying to reinstall NetMQ, I get the same error:
Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
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.
and nuget did not detect that I added 'AsyncIO 0.1.18' in my project.
How to let nuget detect that I added this reference in my project?
Have a look here:
.NET Portable profiles
Profile111 is a combination of:
.NET Framework 4.5
Windows 8.0
Windows Phone 8.1
or in other words:
portable-net45+netcore45+wpa81
So your project into which you are trying to append the NuGet targets Windows Phone 8.1 and other 2 platforms, I mention this one as the most restrictive.
Now let's have a look at the named NuGet package's source:
<ProjectGuid>{3830B7A3-0225-4FDA-B155-E085E183650C}</ProjectGuid>
<OutputType>Library</OutputType>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
What do we have here? We can see that the project is not a PCL. It is targeting full .NET 4.0 framework which is not available on Windows Phone 8.1. And your library does target Windows Phone 8.1. See the problem?
You say that if you compile the AsyncIO targeting .NET 4.5 than you can successfully append it into your project as a reference? That's not altogether true. I mean you can append a reference to it but you cannot use it. You will see that when you try to call something from that reference.
In order to use AsyncIO from you PCL will have to build AsyncIO as a PCL targeting the same or more restrictive set of platforms. Try creating a PCL project targeting Profile111 and try compiling the AsyncIO code with it (just link the original AsyncIO source files (*.cs) into this new AsyncIO_PCL project). If you are lucky enough and the code of AsyncIO is really compatible you will be able to use that library.
Here are your steps:
Create a new project (named AsyncIO_PCL) of type PCL class library.
Pick the Profile111 platform set i.e.
.NET Framework 4.5
Windows 8.0
Windows Phone 8.1
Link all the .cs files from the original AsyncIO project save one (AssemblyInfo.cs) into the new AsyncIO_PCL project.
Set the output assembly name to the same as in original AsyncIO project.
Try building the project.
Your ability to build the AsyncIO as a PCL with the required set of supported platforms depends on AsyncIO code i.e. which API is used inside and if that API is supported by all the three platforms you are targeting.
Try clicking right-button on the project -> Properties. In the "Application" menu check the "Target Framework". It should be set to .NET Framework 4.5
I have a funny error where NuGet will not work in Portable Class Library projects. I have created a portable class library project and when I attempt to search (through the NuGet dialog) or install (through the console) I get the following error:
Specified argument was out of the range of valid values. Parameter
name: supportedFrameworks
I had this error with all projects (Class, etc.) in VS2012 but I followed this advice and it has fixed it except for PCL projects. In a class project the NuGet dialog will list packages and install them just not in PCLs.
What is wrong and how can I fix this?
Note: I am creating a Xamarin Cross Platform project in VS2012 (ie the project is a PCL solution). Maybe this is the cause error - Xamarin's VS Extensions? I am also using VS2012 Professional Trial version - could this be the issue?
Edit Maybe I dont have my PCL setup? For example I dont have the folder C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.5\Profile.
As far as I know Visual Studio 2012 does not include any Portable Class Libraries. They are installed with Visual Studio 2013. Otherwise you will have to install them yourself which involves several steps.
Install the Portable Library Tools and the Portable Library Reference Assemblies 4.6.
Extract the PCLs from the .zip file that the Portable Library Reference Assemblies 4.6 installs into C:\Program Files (x86)\Microsoft .NET Portable Library Reference Assemblies 4.6.
Copy the PCLs extracted into C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable.
Repair the Xamarin install so it adds its PCL profile xml files to the new PCL directories.
I've recently added some custom Portable Class Library projects to an application that is built in an build server. The build was working fine, but after that it stopped working and shows me the following messages:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(983,
5): warning MSB3644: The reference assemblies for framework
".NETPortable,Version=v4.0,Profile=Profile136" were not found.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1578,
5): warning MSB3270: 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\Framework64\v4.0.30319\mscorlib.dll",
"AMD64".
error CS0234: The type or namespace name 'Linq' does not exist in the
namespace 'System' (are you missing an assembly reference?)
The build server specs:
Windows Server 2008 R2 Standard
TeamCity 8.0.4
.NET 4.5
Portable Class Library Tools (as advised here)
Silverlight 5 SDK
The solution is a .NET 4.0 application and the portable projects target .NET4.0+ e Silverlight 5, only.
I have checked my development machine (Windows 8, Visual Studio 2012). There is indeed a folder "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile136" (in fact, the profiles for .NET 4.0 go up to 158).
In the build machine, however, there are only folders for profiles up to 131.
Is Portable Class Library Tools up to date? It seems it miss installing profiles for the most recent platforms.
UPDATE
I copied the ".NETPortable\v4.0\Profile\Profile136" of my development machine to the build server, and now the application builds successfully. I still would like to know why installing the Portable Class Library Tools does not work out of the box.
A more general and elegant solution is to install the latest Microsoft .NET Portable Library Reference Assemblies. This will install profile138 among many others.
The standalone installer(s) can be found at:
4.6 (June 2014):
Copying the desired profile (it is explicit in the error message) from the dev machine to the build server, after installing Portable Class Library Tools, allowed my build to work.
Apparently the Portable Class Library, as it is now, does not include the most up to date portable profiles.
If anyone knows of a more up to date way to get portable profiles on a build server, other than installing VS or copying them manually, I really would like to know.
UPDATE
Path, on my dev machine, for the folder to be copied to the server machine (the path in the server was the same):
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile136
Profile136 came with the version of the portable library targeting pack that was part of the Phone SDK 8.0 (or a later VS Update for VS 2012). The version of the targeting pack you were using is older.