I have some C# code which was originally written in Visual Studio.
I am now trying to make this code run in a Mac, using the Xamarin Studio.
I get multiple errors, that have to do with the references:
For example, the original code uses a library which is called "ClosedXML".
I get an error "The type or namespace nameClosedXML' could not be found. Are you missing an assembly reference?"`
I get such errors on many occasions, for different libraries.
Any way to solve this? Thanks in advance
For each of the The type or namespace name xxx could not be found error, you have to reference the associated assemblies.
For example, you have to add ClosedXML.dll to resolve ClosedXML namespace. It can be done via Nuget -
PM> Install-Package ClosedXML
Or directly downloading and referencing the DLL from here
Related
I am working with a C# version of ncurses called Curses Sharp. So far, I've been following the instructions on how to properly install it.
Through these instructions, I've been able to generate the following files:
When I try to add these as project references in Visual Studio 2019, however, only CursesSharp.dll will import. Attempting to import CursesWrapper.dll results in this error:
This file is necessary for the functioning of CursesSharp. However, I can't find anything online about how to properly import a wrapper into Visual Studio, or what I'm doing wrong. Any help is much appreciated.
Attempting to add just CursesSharp resulted in this error:
You don't need to reference that library directly. It appears tha CursesWrapper.dll is a C++ library that's imported by CursesSharp.dll via P/Invoke (native calls). Just reference CursesSharp.dll and you will be fine. The other library just needs to be present, but it is found automatically.
I have two solutions. Both call extension method "AddDbContext" on an object of type IServiceCollection. Both solutions are .NET 5.
It works fine in one project, but the other project doesn't know about the extension method. Is there an easy way to determine which Nuget package I need to install? Short of Googling (which I can do), is there a simple way in Visual Studio to determine which package contains the extension method?
In the working solution I right click on the call to "AddDbContext" and go to definition. It's in namespace "Microsoft.Extensions.DependencyInjection" in file EntityFrameworkServiceCollectionExtensions.cs. Both solutions have package Microsoft.Extensions.DependencyInjection version 5.0.2 installed on the only project.
The solutions don't have all the same packages installed, but from their names I can't decipher which package installed might be adding IServiceCollection.AddDbContext.
I can Google this, of course, I just wonder if there is some menu in Visual Studio which can just tell me which package contains the extension method?
In this particular case, installing package Microsoft.EntityFrameworkCore v5.0.10 fixed the issue. But why was that package needed, and how could I have determined that using Visual Studio?
If you choose "Peek definition" instead of "Go to definition", then you see the full path of the assembly inside the region at the top of the definition. In the path you see what package it is from.
Some decompiler extensions (such as ILSpy or dotPeek) might also show it in the "Go to definition" view.
Although I have added the System.Web.Http assembly to my project X the HttpSelfHostConfiguration type can not be resolved. And I use resharper...
The odd thing is that the HttpConfiguration works.
When I run some integration tests from project Y using static classes in project X I get a runtime exception: The file or assembly System.Web.Http, Version=5.0.0.0 can not be found etc...
Why can I not resolve the HttpSelfHostConfiguration?
HttpSelfHostConfiguration is located in the assembly System.Web.Http.SelfHost.dll and the namespace System.Web.Http.SelfHost. So you might need to add a reference to this assembly, maybe by adding the Self Host Nuget package.
If you've already added this package, the error might be related to the other errors you're experiencing regarding System.Web.Http v5.0.0.0: I've also experienced some strange behavior after upgrading a Web API project to VS2013. I could only solve this by removing the Web API Nuget packages (the error message resembled yours), deleting some remainders of old versions in the packages folder and adding the required Nuget packages anew.
Solution:
You can add reference from the NuGet Package Library.
Search for Package: Microsoft.AspNet.WebApi.SelfHost
and install it.
For those who has any confusion in adding NuGet Package Reference:
In Visual Studio Solution Explorer, Right Click References > Manage NuGet Packages
I am quite new to C# and Visual Studio but I just downloaded the Facebook C# SDK from NuGet but when I try to use it using:
using Facebook;
visual studio says that it cannot find the namespace name. I checked my references list and Facebook is on the project's reference list.
I tried to follow the instructions from this post on code project.
http://www.codeproject.com/Articles/20032/Creating-a-simple-Facebook-Application-using-WPF
All the examples that I found so far online do not suggest for a problem of that nature.
any suggestions?
Sometimes some NuGet issues require to re-open the project with the referenced assembly to load it. This problem is not Facebook-specific.
This question to which I already found the answer is posted here in case of someone else encounters it. I decided to post the Q&A here so that SO has something about this error, since I don't know if it's been here before.
This occured after an update of the .NET Framework. Before the update, everything compiled just fine! After the update, I could compile nothing!
The error message is:
Error 1 - Could not find file 'Microsoft.Windows.CommonLanguageRuntime, Version=2.0.50727.0'.
This is a problem within Visual Studio 2005. This occurs after an update of the .NET Framework 2.0 and is due to project reference within a single solution.
For example, when you're writing a test library which will test your assembly within the same solution, you will most likely reference the project. Then, this error may occur.
To solve this error, simply reference the file binary of your project, either the DLL or the EXE within which resides the code you want to test. This is called a file reference.
Let's suppose we have two projects called:
Company.Project.ApplicationName;
Company.Project.ApplicationName.Tests.
When adding the reference to our Company.Project.ApplicationName project within our Company.Project.Application.Tests project, we can either use the Browse or the Project tab. When using the Project tab, you create a project reference. We don't want to use this if this error occurs. What we want to use is Browse, so that we can make a file reference.
Here's a link to the Microsoft Support Website that explains this issue.
You may receive a "Could not find file 'Microsoft.Windows.CommonLanguageRuntime" error message when you build a solution of a Visual Basic 2005 Windows Application project in Visual Studio 2005