Visual Studio Xamarin template missing assembly references - c#

Symptoms
I've been attempting to fix my Xamarin forms solution in Visual Studio 2017 RC1 that was generated as a brand new template. While both the android and iOS sub solutions have all their .dll references properly referenced, my UWP (Universal Windows) sub solution seems to be missing essential references to the following .dll files:
'System'
'Xamarin'
'Application'
'Linq'
I was able to locate the .dll references for 'System' and 'System.Linq', in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework, but I'm having trouble locating the specific 'Xamarin' reference for UWP (Windows). I am fairly certain finding the 'Xamarin' reference will also resolve the 'Application' reference as I believe it is a derivative of 'Xamarin'.
Attempted fixes
1. Clean solution
Result: Clean immediately cancels, errors regenerate
2. Create new solution
Result: No change
3. Reinstall Visual Studio 2017 (Several times) and then create new solution
Result: No Change
Specific Error(s)
CS0246 The type or namespace name '-insert reference here-' could not be found (are you missing a using directive or an assembly reference?)
This is happening in project platform -solution name-.UWP in the App.xaml.cs file.

I had the same problem. Unloaded and reloaded the UWP project and suddenly all my lost nuget references appeared (Xamarin.Forms, Microsoft.NETCore.UniversalWindowsPlatform, sqlite-net-pcl, ...)

Turns out the Nuget package needed to be updated.
To do this, use the "Solution Explorer" Window, right click references -> Manage NuGet Packages. A new window will pop up allowing you to update and install NuGet packages.
Alternatively, you can navigate to the Package Manager with Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution.
You can also use the package manager console and use the command: Update-Package to update all packages.

Related

How to work with NugetPackage and LocalProject at same time?

I got an issue working with Nuget packages and local projects.
I am working on a .Net Framework solution, with many projects and many of them are packaged with Nuget in a private repository. I am using PackageReferences to resolve nuget packages. I am working on solution with that kind of dependency tree.
StartUpProject
Project1(LocalProject)
Project2 v1.0.0(NugetPackage)
Project3 v1.0.0(NugetPackage)
Project3 v1.0.1(LocalProject)
When I want to debug or upgrade functionality of packaged project, I remove Nuget package and add that assembly as local project.
When I am navigating in the source code if I try to go to some function from the modified project, Visual Studio open the code as external assembly and does not resolve like local project.
Maybe the problem is other Nuget package (Project2) depends from I removed Nuget package (Project3) and Visual Studio still resolving that assembly as Nuget package.
The error that Visual Studio throws at compilation is CS0433: The type 'MyType' exist in both'Project3 , Version=1.0.0, ...' and in 'Project3, Version=1.0.1, ...'
What is way to work in that cases?
Is any way to force to use local project than dependency nuget package?
Thank you!

Unity can't find package installed with Nuget in Visual Studio

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.

Adding an ADO.NET Entity Data Model throws build errors

I am using Visual Studio 2013 express. I create a new project and then I add a database to that project. But, when I add an ADO.NET Entity Framework model to that project and then run the program, I get the following four build errors listed below. To try to remedy this myself, I added the namespaces 'System.Data.Entity' and 'System.Data.Entity.Design', but that didn't help. Also, I uninstalled and re-installed the Nuget package. I also uninstalled and re-installed Visual Studio 2013 Express for Windows Desktop. But these measures didn't help the situation either.
Please note that I used to use the Entity Data model just fine. But it was around the time that I did a system restore on my computer, and when I updated VS 2013 with an update offered on the start page, and finally, when I signed up for MS Azure, that I started running into the problem described above. Now I would think that uninstalling and reinstalling Visual Studio 2013, and then installing the 'Nuget' Package would solve all problems. What am I missing here?
The errors mentioned above are:
Error 1 The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?) C:\Users\John\documents\visual studio 2013\Projects\Riches\Riches\RichesModel.Context.cs 14 30 DataLayer
Error 2 The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) C:\Users\John\documents\visual studio 2013\Projects\Riches\Riches\RichesModel.Context.cs 16 52 DataLayer
Error 3 The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?) C:\Users\John\documents\visual studio 2013\Projects\Riches\Riches\RichesModel.Context.cs 23 49 DataLayer
Error 4 The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?) C:\Users\John\documents\visual studio 2013\Projects\Riches\Riches\RichesModel.Context.cs 28 16 DataLayer
Thank you and I realize that my last attempt at this question was rather rough-draftish,
John
By opening 'Tools', 'Nuget Package Manager', 'Manage Nuget Package bySolution', then in 'Updates' uninstalling the check-boxes that show my dbase and its one table, and then, in the 'online' section, reinstalling with the purple-colored icon for the entity framework, then all of the references populated in the solution explorer for the EF and data extensions. And the compiler can find the library it needs to run. So the program runs fine now with the EF model added.
That other error window that you mentioned which was re: NuGet.VisualStudio.Interop I had gotten before I added Nuget at all. It was your pointing to adding Nuget to a particular solution that directed me to look in the 'Manage Nuget Package by Solution' item.
The evidence points to needing to install all of the updates manually, particularly from the Nuget Package Manager in addition to installing Visual Studio 2013 (Express). Say, for instance, if you have to restore your system to a point before you ran the update from your start screen. So in this case that you don't have access to that update from your start screen, you would now have to install VS 2013, then install Nuget from either 'tools' 'extensions and updates' or from 'tools' 'Nuget Package Manager', then install 'Entity Framework' from 'Manage Nuget Package by Solution'.
John
Install Entity Framework package by Package Manager Console. Open it (tools menu) and type:
Install-Package EntityFramework
Then let us know is it work now. (Entity Framework should be visible, when you expand References node in Solution Explorer)

Visual Studio 2010 cannot add Newtonsoft.Json Library

I've got a Problem with Visual Studio 2010 and the Newtonsoft.Json library.
A few hours ago nothing was wrong with my project, but now it throws this error
The type or namespace name 'NewtonSoft "could not be found. (Missing a using directive or an assembly reference?)
--I just saw that the Reference was deleted and i can't re-add the NewtonSoft.Json library.
You can use the package manager console to remove the package, if you're having trouble getting NuGet to uninstall or reinstall it using the GUI:
Uninstall-Package Newtonsoft.Json
Be sure you've selected the right target project from the dropdown at the top of the console if your solution contains several projects.
Make sure that the .NET framework version your project targets is the same or higher than the one your Json.NET nuget package requires.

Error 22 The "EnsureBindingRedirects" task could not be loaded from the assembly

I cloned a project with vs 2013. When I run it I get this error.
Error 1 The "EnsureBindingRedirects" task could not be loaded from the assembly D:\BMaster\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.Tasks.dll. Could not load file or assembly 'file:///D:\BMaster\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. BargainMaster.Web
I'm not sure about root cause of this issue but it appeared when I added missing libraries by hand.
I resolved it by doing this:
Delete <solution>\packages\Microsoft.Bcl.Build.1.0.13\
Close solution
Open solution
Navigate to View / Other Windows / Package Manager Console
Press Restore Packages in right top corner of the window
Re-build
(For some reason none of the other answers worked for me.)
I resolved the issue by doing this:
Delete the "packages" folder.
Right click on the solution > Manage NuGet Packages or Solution.
Downgrade Microsoft.Bcl.Build to a previous version 1.0.14. (Latest stable version at the moment of writing this is 1.0.21)
Restore packages and rebuild.
I just went to the Manage NuGet packages options for the particular VS project and updated the version of the Microsoft BCL nuget and it solved the problem for me.
Verify that you have Nuget Package Manager installed.
By default, Visual Studio 2010 doesn't have it (later versions do)
- Open Tools / Extension Manager
- Search for Nuget Package Manager and click Download
- After this I had to remove the Nuget package (Microsoft.Bxl.Async, Microsoft.BCL, and Microsoft.Bcl.Build) causing the error, restart VS and re-add the package.
The above answer didn't work for me. I just had to remove references (in packages and proj file) to Microsoft.Bcl.Build.. Rebuilt and succeeded.

Categories

Resources