Website reference and objects code errors - c#

I have a project which is a website working with SQL database. It is not my project but it is my website and I finally managed to get the source code from the coder. Long story....
I have loaded the project in VS2012 and managed to get the third party component Telerik and to sort out initial problems.
Now I am stuck with a series of errors related to something I do not understand how to solve. Please look at the picture:
I think it has something to do with the framework. It was developed in VS 2005 and framework 2. I am now in VS 2012 and framework 4 but I may be wrong. Please can you give me a direction on how to solve these errors?
Error 1 the name 'errlbl' does not exist in the actual contest. C:\Users\Pink\Documents\Visual Studio 2012\Projects\Stadler_new\login.aspx.cs
Error 2 the name 'RadMenu1' does not exist in the actual contest. C:\Users\Pink\Documents\Visual Studio 2012\Projects\Stadler_new\projects.aspx.cs
Errore 15 the name 'Button2' does not exist in the actual contest. C:\Users\Pink\Documents\Visual Studio 2012\Projects\Stadler_new\Search.aspx.cs
and so on.....

Related

Error MSB3095 when compiling a Windows Form Application

When I try to compile any Windows form application project, I get an error saying:
\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2114,5): error MSB3095: Invalid argument. Culture is not supported.
\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2114,5): error MSB3095: Parameter name: name
\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2114,5): error MSB3095: x86 is an invalid culture identifier.
I was using VS 2017 when I stumbled across this error message. After searching the net, I saw that the problem I had was never asked by someone else. So I uninstalled anything related to Visual Studio and installed VS 2019.
With all my efforts to solve this problem going down, I checked if there was a conflict with my application's references and the MSBuild assembly files. This was also not the solution. Right now I am two weeks behind my schedule and yet still have no answers.
I tried changing platform target and target framework, hoping to see a difference but no; nothing has changed.
I also tried other application projects & targets. Here is the result:
Compiling a console application does not raise an error message.
Compiling a Windows Forms application, however raises the same error message with different projects.
The reason to error MSB3095 is actually not totally specific but it may be caused by the directory which your project is in, like it was in my case.
So simply move your project to another directory, that does not consist a non-ASCII character in. It will most likely solve it.

CSharpAddImportCodeFixProvider encountered an error and has been disabled

I had my PC re-imaged for me. I have Visual Studio Version 14.0.25123.00 Update 2 installed on my computer. I'm getting this error when I try to use VS intellisense to reference another project.
CSharpAddImportCodeFixProvider encountered an error and has been disabled
I have two projects. One of them using namespace ProjectName.Web. And the other project using ProjectName.Web.Controllers. The provider crashes when I reference ProjectName.Web.Controllers, I believe because it is setup as a project. Any idea how to fix this?
I had the same issue on VS-2015 update 3.
I did was :
1) Closing visual studio
2) restarting as administrator
Happened to me when chose Add using System.Data.SqlClient automatically after typing using (SqlConnection...){} in DataLayer, in one of Repository classes.
Nothing helped (except creating new project), but I saw that the problem was with loading System.Data.SqlClient.dll file, although it existed in appropriate folder.
Found by trial and error that after removing Dependencies->Assemblies->System.Data.SqlClient from DataLayer (right click -> Remove, or just press Delete key when selected), I can Add System.Data.SqlClient without any errors.
Didn't try for other cases where CSharpAddImportCodeFixProvider encountered an error and has been disabled message appears, but the solution might be similar.
In my case the problem appeared probably due to .net Core version conflict or something like that, because the project was on external drive and created on another computer.
Edit: Also, some errors might be caused by .vs folder (hidden by default) inside Solution folder, especially if the project is moved between different computers. I know from experience that IntelliSense can seem to be broken and classes from other namespace would be unavailable although using namespace_name statement is present. The solution is to delete .vs folder or just avoid copying it with the project, as suggested here: https://weblog.west-wind.com/posts/2018/Aug/07/Fixing-Visual-Studio-Intellisense-Errors
There may be multiple reasons why this error occurs. So this answer may not apply to all situations, though it seems that it only occurs when another project is referenced.
The error does not occur for all statements. In my case I had the following code:
private System.Threading.Timer Timer;
public void Start()
{
Timer.Change(0, 60000);
}
As soon as intellisense would open for Timer.Change( the error occurred. Please note that I had no parameters at that point. If valid parameters are present there will be no error.
I could solve the issue by updating the version of the framework. I found out that both projects targetted different frameworks, resp. 4.5.2 and 4.6.
As long as the framework versions are different the error occurs. As soon as both are equal (either 4.5.2 or 4.6) the error no longer shows.
I have tested this with VisualStudioVersion = 14.0.25420.1 (Visual Studio Community 2015).
-- update --
I've reported this as a bug to Microsoft. Including steps to reproduce.
I end up with this same error.
what i did was to manually go and find the nuget packet for System.Data.SqlClient, installed and then invoke it in the class i was working on, like:
using System.Data.SqlClient;
Dont know if this is some kind of bug, cause it happens on a new blank project i create using visual studio 2019 community
hope it helps someone
Had the same problem solved by installing the sqlClient package from nuget package manager
right-click on the project choose manage nuget packages.. and go to browse tab and search for System.Data.SqlClient and install it. that easy :)
Judging from the label you were given, "CSharpAddImportCodeFixProvider", I'd guess your problem was due to Visual Studio trying to identify and/or correct a missing "using" statement at the top of your C# source code file in which you made reference to a class that needed it. The Visual Studio components that usually deal with this type of problem are Intellisense, or third-party syntax highlighting/correction plugins like JetBrains' ReSharper.
On second thought, I'm not quite sure it's Intellisense's fault as opposed to the plugin ReSharper's. That's to be determined.
I did file a similar bug report with Microsoft. The error in my case seemed to be a result of the Intellisense not knowing how to deal with a logic error in my own code (see https://connect.microsoft.com/VisualStudio/feedback/details/3133049).
In my case, I had inadvertently placed code for a method outside its class definition, though inside its similarly named namespace. Visual Studio 2015 Update 3 complained,
'GenerateVariableCodeFixProvider' encountered an error and has been
disabled.
The fix was to move my method back into its corresponding class definition, but it definitely brought a Visual Studio bug up to the surface.
Specifically, Visual Studio Intellisense had seen the line of code,
Response.Write("I did something");
placed in a method that was declared outside a class definition (i.e., inside a namespace, but inadvertently not inside its class). The "'FeatureLabel' encountered an error and has been disabled" error was then displayed in a yellow bar across the top of my editor window and an "Enable" button and an "Enable and ignore future errors" button were displayed next to it.
I believe that Intellisense (or ReSharper?) tried to automatically deal with the situation and attempted to generate a variable for the keyword, "Response", but it tripped trying to do so--which in turn caused the error that was displayed.
anyone trying this solution from here ?
https://developercommunity.visualstudio.com/content/problem/623872/add-import-not-working.html
the last reply solves my issue..
Tools > Options > Text Editor > C# > Advanced
turning off Suggest usings for types in NuGet packages

Entity Framework - "Compiling transformation: The metadatafile ../IDE/EntityFramework.dll wasn't found"

I've been having this problem for a while now, but found a cheat way to avoid it.
Everytime I create a new .edmx file, update a current .edmx, or basically do anything that has to do with Entity Framework, I get the following error:
Compiling transformation: The metadatafile ../IDE/EntityFramework.dll wasn't found
Everytime I've worked in a group, I've avoided this error by simply letting the other members of the group update the .edmx file. But as I'm working alone at the current moment, I've had enough of this, and wish to put this to an end.
I've installed Entity Framework through nuget, and I've tried uninstalling and reinstalling EF with no luck at all.
Am I the only one with this problem? And do any of you have a solution to this strange error?
Please ask for code or anything you need, and I'll provide.
Managed to solve the problem on my own.
As I'm working on a laptop with two drives (SSD & HDD), I've installed VS on my HDD (D:/).
I changed my environment variable VS120COMNTOOLS to be D:\Programmer\Visual Studio Ultimate\Common7\Tools\ instead of C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tool\, restarted VS and everything now works.
I've had this problem for a while, and finally managed to fix it. If anyone else has this problem and don't quite know what exactly I did, please tell so, and I'll compile some images of the steps, as this is the most frustrating error I've ever encountered.

An exception of type 'System.IO.FileLoadException' occurred in Ninject.dll but was not handled in user code

I am following the Pro ASP.Net MVC5 book by Adam Freeman. I have created the sportsStore project as per the chapter 7. And after creating the project templates and adding the references, I build the project and try to debug it. I get this pop-up box
And if I click on cancel, I get the exception mentioned in the question. I am not able to figure this out. Any suggestions
I get the above error when I click on cancel.
Here is the call stack of the exception -
Ninject.dll!Ninject.Modules.AssemblyNameRetriever.GetAssemblyNames(System.Collections.Generic.IEnumerable<string> filenames, System.Predicate<System.Reflection.Assembly> filter) Line 54 C#
Ninject.dll!Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(System.Collections.Generic.IEnumerable<string> filenames) Line 81 C#
Ninject.dll!Ninject.Modules.ModuleLoader.LoadModules(System.Collections.Generic.IEnumerable<string> patterns) Line 54 C#
Ninject.dll!Ninject.KernelBase.Load(System.Collections.Generic.IEnumerable<string> filePatterns) Line 237 C#
Ninject.dll!Ninject.KernelBase.KernelBase(Ninject.Components.IComponentContainer components, Ninject.INinjectSettings settings, Ninject.Modules.INinjectModule[] modules) Line 100 C#
Ninject.dll!Ninject.KernelBase.KernelBase(Ninject.Modules.INinjectModule[] modules) Line 60 C#
Ninject.dll!Ninject.StandardKernel.StandardKernel(Ninject.Modules.INinjectModule[] modules) Line 48 C#
SportsStore.WebUI.dll!SportsStore.WebUI.App_Start.NinjectWebCommon.CreateKernel() Line 38 C#
Ninject.Web.Common.dll!Ninject.Web.Common.Bootstrapper.Initialize(System.Func createKernelCallback) Line 50 C#
SportsStore.WebUI.dll!SportsStore.WebUI.App_Start.NinjectWebCommon.Start() Line 23 C#
[External Code]
.
I understand that the AssemblyNameRetriever class is missing and I did try to fix it by downloading it from github and using that class. But again it gives some exceptions. Shouldn't the Ninject take care of this class by itself.
Looking at your exception, you are trying to load Mvc Version 3.0.0.0. You are currently running a different Mvc version.
If you have the source code to the projects that depend on the older Mvc version, you can try to re-compile them with the newer version. You can also try messing with the dependencies to have the right version across the board.
There is also a code project page with a person with a similar situation. The author writes:
After reviewing the code pes1957 sent to me I was able to determine that there was indeed an assembly reference error.
Basically the number of projects that were in the solution had a mixture of version 5 and 6 Entity Framework references. I updated the references, and web.config to show the correct version number and all compiles correctly.
The same problem occured in my project. It seems that installing NInject from nuget package as first one caused the Ninject library wants System.Web.MVC v3. After uninstalling all Ninject library from nuget package manager and adding NInject.MVC5 package as the first and only package, the problem was solved.
I came across this issue and turned out my MVC web project was referencing another MVC Web API project, Ninject error was coming from the Web API project. In my case I removed the reference to keep things simple.

.Net Project Build Issues

I have a project (1 of 41) that will not load in Visual Studio 2012. I have inherited the solution and am attempting to get the environment spun up. There was an error stating that SQLServer.targets could not be found so I copied the file from my 3.5 folder to the 4.0 folder. Now, I am receiving the following error when attempting to reload the project:
error : Unable to cast object of type 'Microsoft.VisualStudio.Data.Tools.Package.Project.DatabaseFileNode' to type 'Microsoft.VisualStudio.Data.Tools.Package.Project.Internal.FolderNode'.
Any thoughts? I feel like I am spinning my wheels at this point. Thank you.
I had the same issue converting a class project that contained CLR stored procs for SQL Server. The VS 2012 conversion attempted to convert this to a sqlproj, but failed. Rather than try to track down the source of the problem, I removed the project from the solution, added a SQL Server Database Project, then dropped my code files into that new project.

Categories

Resources