System.Data.Linq not loaded in MVC .NET 4.5 - linq

I have an ASP.NET MVC4 Web Application project in .NET 4.5 (VS 2012). It is in VB.
It fails loading System.Data.Linq namespace (with all classes and sub-namespaces).
Project has a reference set to System.Data.Linq.dll.
Any ideas where is the problem?
When I try to add Linq2Sql classes, I get such warning:
Namespace or type specified in the Imports 'System.Data.Linq' doesn't contain
any public member or cannot be found. Make sure the namespace or the type is
defined and contains at least one public member. Make sure the imported element
name doesn't use any aliases.
and such errors:
System.Data.Linq.DataContext
But this is just a beginning: if I try to use anything from System.Data.Linq namespace I get an error, for example if I try to use System.Data.Linq.Mapping.DatabaseAttribute, I get such error:
Type 'System.Data.Linq.Mapping.DatabaseAttribute' is not defined.

I had this same problem - and was able to get past it. I'm not entirely sure which of these steps resolved the issue - but this is what I did.
I had originally created the dbml under app_code/gcm
I removed references to System.Data.DataSetExtensions
I deleted the dbml and recreated it outside of the app_code folder
I built the project (no errors/warnings)
I moved the dbml back to the app_code folder and rebuilt (again no errors/warnings)
Hope that helps you get around this.

Related

Deleted files gives CS0246 compiler error in VS2022

I've added 3 default Blazor projects to my solution.
Blazor WebAssembly1
Blazor WebAsssembly2
Blazor Server
The first WebAssembly project is converted to a razor library in order to share code between server and webassembly projects. I also deleted the default pages like FetchData.razor and such.
On compilation I still get compile error on this (the app runs fine though), and I can't seem to resolve them. I've search through the entire solution but can't find any of the files that results in the compile errors.
How to locate the reason for the errors and remove the references? The files are deleted from the project.
Example of compiler error:
CS0246 The type or namepace 'WeatherForecastService' could not be found (are you missing a using directive or an assembly reference?)
The errors in FetchData indicate a problem with the using statements.
Try to check if you have global using, try to remove and declare explicit in the razor page.
Check your CSPROJ and verify the project type, in the RCL the type must be:
<Project Sdk="Microsoft.NET.Sdk.Razor">
In the RCL you haven't a Program/App structure, you have only components and wwwroot elements.
My RCL is composed as follow:
I have also a _Imports.razor with:
#using Microsoft.AspNetCore.Components.Web
...
The issue resolved itself when I restarted Visual Studio.
Sorry for the wild goose chase

Visual C++ error with two projects: name followed by '::' must be a class or namespace name

I'm new to Visual C++. I have two separate projects (let's call the first Converter and the second TreeGridView). I have this line of code in the Converter project:
private: AdvancedDataGridView::TreeGridView^ treeGridView;
which throws this error on 'AdvancedDataGridView':
name followed by '::' must be a class or namespace name
I think I understand the error - Visual C++ can't find a class or namespace called 'AdvancedDataGridView' right?
I have a separate Visual Studio project called TreeGridView which has 3 C# projects included in it. One of the projects has an assembly name of 'ExpandableGridView' and a default namespace of 'AdvancedDataGridView' and an output of type Class Library. Another project has an assembly name of AdvancedDataGridView and a default namespace of AdvancedDataGridView and an output type of Windows Application.
Being new to Visual C++ and the codebase I'm using, I'm not sure how to make the error go away. The TreeGridView project (the one with 3 c# projects) does generate an ExpandableGridView.dll file which I've added a reference to in my Converter project, but the error persists. Intellisense doesn't find AdvancedDataGridView at all. Any ideas?
Additional info: When adding the ExpandableGridView.dll as a reference, I get a yellow warning triangle icon on the reference and 'Full Path' in the properties says
The "Microsoft.VisualStudio.ProjectSystem.References.UnresolvedAssemblyReference" reference
could not be resolved.
Solved. I had two references to the same ExpandableGridView dll file - got rid of both of them, then added the latest dll again - after that the error and warning I mentioned above went away.
You're trying to XOR a type with a variable? Pointers are declared using type*, not type^.
See http://www.cplusplus.com/doc/tutorial/pointers/ for a tutorial on C and C++ pointers.

Error building DataAnnotationsModelBinder project to get the Microsoft.Web.Mvc.DataAnnotations.dll

I am refering to the "Validation with Data Annotations tutorial" here http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validation-with-the-data-annotation-validators-cs for my database first MVC3 project. I downloaded the DataAnnotationsModelBinder project but having difficulty building it. It throws following errors:
Error 1 'System.Web.Mvc.IValueProvider' does not contain a definition for 'DoesAnyKeyHavePrefix' and no extension method 'DoesAnyKeyHavePrefix' accepting a first argument of type 'System.Web.Mvc.IValueProvider' could be found (are you missing a using directive or an assembly reference?) C:\XYZ\DataAnnotationsModelBinder\src\DataAnnotationsModelBinder.cs 47 17 Microsoft.Web.Mvc.DataAnnotations
Error 2 Metadata file 'C:\XYZ\DataAnnotationsModelBinder\src\bin\Debug\Microsoft.Web.Mvc.DataAnnotations.dll' could not be found Microsoft.Web.Mvc.DataAnnotations.Tests
Am I missing anything? I tried using VS2008 as well as VS 2010.
Please help.
I'm assuming that you have some missing references, so you need to include the missing references in the project.
You can do this by right clicking the references folder and add them manually. (see image)
Refrences - image
You should not use the DataAnnotationsModelBinder with MVC3. The DefaultModelBinder class already contains all of the logic that was present in the DataAnnotationsModelBinder sample you have linked to.
You probably need to add a reference to System.Web.Mvc 1.0 instead of what you're got at the moment.

Can razor use an object from an exe as opposed to dll for View in ASP.net MVC

I have a project which sends the status of a system via XML to a client. I have another project that is an ASP.Net MVC project. If I use the dll of the first project then I don't have any problems. If I use the exe from the first project then I get the following error:
The type or namespace name 'XXXX' does not exist in the namespace 'YYYYY' (are you missing an assembly reference?)
I think this error is when the page is render. I am not sure how razor works but it seems to create temporary classes.
public class _Page_Views_Status_Index_cshtml : System.Web.Mvc.WebViewPage<xxxx.yyyy.Monitoring.SystemStatus>
Are we not able to reference classes in an exe? I don't see any reason why this shouldn't work.
Probably the class that you are trying to use is located in the DLL and not the EXE, so you need to reference the DLL. You could also reference EXE (assemblies) but in this case make sure that the class that is shown in the error message is actually present in this EXE.
So you could have the following solution structure:
SomeProjectLib (Class library containing the YYYYY.XXXX class)
SomeProjectWin (An exe which references the class library and uses the class from it)
SomeProjectWeb (An ASP.NET MVC project which references the class library and uses the class from it)

Visual Studio namespace errors after deleting userControls

Really Visual Studio can be so annoying sometimes...
I did nothing else than deleting 3 UserControls in a folder. Since that time I get a error message I do not get rid of. Whatever I do I can not build successfully my project.
I did not touch the SchoolAdministrationUC.xaml file , but I deleted 3 other UserControls also located in the path: TBM\View\SchoolclassAdministration\
Error message from VS:
Error 1 The type or namespacename "SchoolclassAdministration" is in namespace "TBM.View" not available. (missing assembly reference?) E:\TBM\obj\x86\Debug\View\SchoolclassAdministration\SchoolAdministrationUC.g.cs 33 16 TBM
How do I get rid of error ?
Well, the fact that it shows the obj folder as where the error is, have you tried a clean build? Or a complete rebuild?
Sounds like there is an object out there looking for a non-existent namespace.
Build -> Rebuild Solution
This error comes up when you unwittingly create a new Windows application Project to add the existing code for a class library project in the same project folder. If the original class library project is not compatible with VS or you have any other issue then creating a new class class library is an option.

Resources