Unable to compile C# code on Mac - c#

I am receiving an error when I try to compile my c# source code file on my Mac. Normally I compile my source code using the mcs command on a bash terminal window and it compiles fine. But, this one particular project requires the installation of the NuGet package 'MySql.Data'. This has resulted in the following error message:
error CS0246: The type or namespace name 'MySqlConnection' could not be found. Are you missing an assembly reference?
I have tried to follow numerous solutions online to try and add the assembly reference, but my IDE just does not look like the help documentation's screenshots.
I have tried to Edit References, but no references appear. I tried to manually download the MySql.Data.dll (v.6.3.5.0) but I think it is for an outdated version of the MySql.Data class library as it does not work. Even after cleaning the code and rebuilding it.
Edit: I have also tried to add the dll that was included in the project folder but it said it could not locate the assembly (even though they are both in the same project folder).
Could not resolve this reference. Could not locate the assembly "search_feature". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. (MSB3245) (search_feature)
Edit 2: I renamed the dll file from the project bin folder to MySql.Data.dll and I no longer get the error. But it still won't compile.
The code works fine when run in Visual Studios for Mac, but I just can't compile it. Any ideas how to add the assembly reference?
I am using the most up-to-date version of Visual Studios:
Visual Studios for Mac Community 7.5.4 (build 3)
I have tried uninstalling and reinstalling Visual Studios for Mac.
My code has the library reference at the top: Using MySql.Data.MySqlclient; and the project runs. It just won't compile.

Related

VS2019 RegPkg.exe throws Unhandled Exception

I've just installed Visual Studio 2019 with SDK and when i try to run RegPkg.exe, I see the following error. I don't have any other VS instances installed on the machine but I'm confused why the error is reporting about version 15.0.0.0 (which is VS2017).
Can someone please help me to resolve this error.
Unhandled Exception: System.IO.FileNotFoundException: Could not load
file or assembly 'Microsoft.VisualStudio.Shell.Framework,
Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or
one of its dependencies. The system cannot find the file specified.
at Microsoft.VisualStudio.Tools.RegPkg.Main(String[] arguments)
I just noticed I got the exact same error message, using VS 2017's version. So it has nothing to do with the version you are using. I don't even have 2019 installed.
Microsoft simply broke their SDK, which has apparently been broken for 2 years, and no one noticed. For reference, I'm using VS 2017 15.9.7, also with the VSSDK installed.
I have a NuGet reference to that DLL in a VSIX extension I build, so I had a copy in my .nuget package cache ("%USERPROFILE%.nuget\packages\microsoft.visualstudio.shell.framework\15.9.28307\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll"). I copied that version into the folder where regpkg.exe is located, and resolved the error (%VSSDK150INSTALL%\VisualStudioIntegration\Tools\Bin).
Probably not the best solution, but Microsoft needs to fix their product. I suspect it broke as part of their reorganization for the 2017 product, as they also added all the assemblies that extensions need for dependencies to NuGet. I guess they forgot to keep that assembly in the actual VS install folder.
EDIT: I've been looking into this more, and apparently the file actually exists in the lib sub folder right there with the exe. However none of the versions I've found actually work with CreatePkgDef.exe which was my backup plan, as it now throws this error instead:
CreatePkgDef : error : ArgumentException: No Visual Studio
registration attribute found in this assembly. The assembly should
contain an instance of the attribute
'Microsoft.VisualStudio.Shell.RegistrationAttribute' defined in
assembly 'Microsoft.VisualStudio.Shell.Framework' version '15.0.0.0'
Seems to work with regpkg.exe, though I haven't tried every combination of options.

Build succeeds even though the editor shows errors and and installation of NuGet package fails

In Visual Studio 2017, I have a solution with the following projects:
My.Project
My.Project.Commons
Test.My.Project
Test.My.Project.Commons
In one of the test files from Test.My.Project, I have this statement:
using My.Project.Commons;
If I hover over it, it shows this error message:
The type or namespace name 'Commons' does not exist in the namespace
'My.Project'(are you missing an assembly reference?)
However if I Clean and Build(or Clean and Rebuild) the solution, there are no errors.
When I try to install a NuGet package, I get the same error:
The type or namespace name 'Commons' does not exist in the namespace
'My.Project'(are you missing an assembly reference?)
So why does my build succeed?
I believe that my Test projects are not built properly, because I can't run any tests.
On another solution however, I can run tests with no problem, so I doubt there is an issue with Visual Studio as a whole(just with my current project).
I tried:
Restarting Visual Studio.
Removing all projects from the solution and adding them back.
None of these things worked though.
If you are using resharper, suspend and resume resharper and it will refresh the cache
If you go into VS options resharper you will find the the options

Namespaces not recognized though they exist in VS 2010

In the C# VS2010 Solution I'm working in, there is a namespace called: EBI.Core.Base.Constant.EBISystem
That namespace's DLL is referenced as a Project (i.e. a project native to the solution,) in a different project in the same solution.
VS shows error saying that: The type of namespace Base does not exist. This is true, it does not exist because the actual name is the full namespace name above.
When I remove the project reference and add it back in, the error goes away and the full namespace name is recognized, but as soon as I build, the error comes back. Same thing happens if I close the solution and re-open it, no error, until I build.
This error seems to be happening only on my dev machine and no one else's with the same exact solution.
I looked at my GAC and there's no stray or missing dll there. I have closed and restarted the solution, I have restarted my machine to no avail. Also checked project build dependencies and they are correct. Unloaded and released the project, still the same thing.
Both the project being worked on and the referenced project are .Net 3.5.
Wondering if anyone has any suggestions. I've tried everything here: Getting "type or namespace name could not be found" but everything seems ok?
Use the same target framework version for your project and the library "EBI.Core.Base.Constant.EBISystem"

VS 2010: C# Project Cannot Open DLL

I'm having an issue building a project that references a DLL located in the project's bin folder, which up until yesterday was building and running without issue.
The error I'm getting is fatal error CS0009: Metadata file 'c:\MyProject\bin\myClient.dll' could not be opened -- 'Error importing module 'myClient.netmodule' of assembly 'c:\MyProject\bin\myClient.dll' -- The system cannot find the file specified.' Intellisense is similarly complaining that The type or namespace 'Api' does not exist in the namespace 'Client' since it can't find the DLL.
Let me know if you think this is a duplicate, but I've viewed several similar posts and the solutions did solve my problem. Here are some examples:
Visual Studio 2010 — are you missing a using directive or an assembly reference?
VS2010 - Getting “type or namespace name could not be found” but everything seems ok?
Stymied by ASP.NET Compilation Error CS0009
Metadata file '…\Release\project.dll' could not be found in Visual Studio
Visual Studio 2010: Metadata file “…/Debug/Graph.dll” could not be found
Metadata file … could not be found error when building projects
Specifically, I've tried the following solutions (and combinations of these):
Cleaned and rebuilt my project.
Made sure that the target framework is not a 'client profile' version of .NET
Verifyied that the dll has been added as a project reference
Removed and re-added the project reference
Verified that the project is showing the DLL in the References section in Visual Studio
Repaired .NET
Verified the location of the DLL (it is in the local project's bin folder as given by the error)
Tried other versions of .NET
Closed and restarted Visual Studio
Rebooted my machine
Verified there are no hidden characters surrounding the 'using' statement
Removed all code changes since the last working build
Verified the settings in Configuration manager, including that 'Build' is checked
The project calling the DLL is a small class library that resides in a solution with one other small project (a console application). The DLL is an external DLL that I've been using successfully for several weeks in this project/solution. The error arises regardless of whether I build the project from the solution or by itself.
Any ideas about what could be going on?
Have you included bin folder in your project accidentally? If yes that might cause the issue. You can't include bin folder in your project as the bin folder will be created by the VS. If you accidentally include bin folder in your project, the bin project will be set to Copy to output which when you compile, the file is deleted and copied to output by Visual Studio that trigger weird behavior that some file is missing.
Hopes this help
Well I'm not sure exactly what happened here, but here is what finally resolved the issue:
A good-old-fashioned delete every single file and rebuild the project from those files from scratch. I gave +1 to some of the responses because they were useful to consider, and because there was probably a messed-up reference some where as Jonathon Wood suggested.

Can't compile WebKit .NET 0.5 in VS 2010

I'm trying to compile WebKit .NET 0.5 in VS 2010 Professional but I'm getting the error:
"Could not load file or assembly
'C:\Users\Juan
Luis\Desktop\WebKit.NET-0.5-src\bin\Debug\WebKitBrowser.dll'
or one of its dependencies. The system
cannot find the file specified."
I tried removing the WebKitBrowserTest project from the solution but now I'm getting
"The type or namespace name 'WebView'
could not be found"
errors everywhere. Any idea what am I doing wrong?
replace the .dll in the projects debug folder with the original .dll's. When VS make a copy of the .dll's, it does something wrong, replacing them should fix the problem.
Try to copy '\WebKit.NET-0.5-src\bin' to your 'bin' folder.
With me, I can't build whole solution, but it runs when I select WebKitBrowserTest as StartUp project, then Ctrl + F5 (Visual Studio would ask me for rebuild JSCore, just click Yes).
If you see an error like "Retrieving the COM class factory for component with CLSID...",this link can help http://dotnetgenetics.blogspot.com/2013/06/retrieving-com-class-factory-for.html

Categories

Resources