Intellisense stopped working for Linq to Entities - c#

I have this simple code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Linq;
using GadNameSpace;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GadEntities db = new GadEntities();
var images = db.Images.Where(x => x.isApproved == true).ToList();
Repeater1.DataSource = images;
Repeater1.DataBind();
}
}
Now if I'm trying to edit this line:
var images = db.Images. <--this is where intellisense is not working...
It worked before. Same file, same project, same Solution.
If I'm writing the code manually and run it, its working fine.
I tried start > cmd > "devenv /ResetSettings"
I tried to restart pc also.
The problem is with Linq intellisense only! for anything else intellisense is working fine...
Any good ideas?

Usually this happens to me when a reference to System.Data.Linq.dll is missing from the module.
I bet you have your data context in yet another assembly where the reference is set correctly (so that the code works when you compile it) but in the same time the reference is missing from the web application (and thus VS does not show the intellisense).

Sometimes, reference of EntityFramework could be missing. Please make sure that the same exists in the project you're working on.

Related

ˋ[System.Version]::Parse('')´ error in Xamarin

I have been trying to create a custom control on Xamarin.Forms.
My solution builds just fine on UWP but with android I always get the same error :
Impossible to evaluate the expression "[System.Version]::Parse('')". String is either too long or too short.
How Can I solve this ???
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using App2;
using App2.UWP;
using Xamarin.Forms.Platform.UWP;
using Windows.UI.Xaml.Controls;
[assembly: ExportRenderer(typeof(NavigationPannel), typeof(NavigationPannelRenderer))]
namespace App2.UWP
{
class NavigationPannelRenderer : ViewRenderer<NavigationPannel, NavigationView>
{
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPannel> args)
{
base.OnElementChanged(args);
if (Control == null)
{
NavigationView nav_view = new NavigationView();
nav_view.MenuItems.Add(new NavigationViewItem
{
Content = "My content",
Icon = new SymbolIcon(Symbol.Folder),
Tag = "content"
});
SetNativeControl(nav_view);
}
}
}
}
EDIT :
I made another solution and tried to redo everything step by step, my android project compiled just fine at first, but when I Added my UWP custom renderer, and after compiling it on Windows, it started showing the same error
Okay so I made it step by step again copy/pasting line by line for a third time and this time no error occurs.
I really don't know what happened here so if anyone has any idea i would still gladly accept it.

Could not load type 'XXXX.aaa'

Hi,
I am having Could not load type error when I release my code into live environment. If I remove the code Inherits="CheckIEBrowser.Check" that gets rid of the error, it displays the page, but it doesn't work as it should.
Thanks in advance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CheckIEBrowser
{
public partial class Check : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!(IsPostBack))
{
...
Make a copy of Check.aspx and its CS fle to your local
Delete Check.aspx and Check.aspx.cs manually from directory
Clean Solution
Right click your solution add new form and name it as Check.aspx
Copy your local saved check.aspx contents to Check.aspx that we created newly (except line 1 )
do the same for check.aspx.cs also
rebuild your solution
Than try
if its not work, delete CheckIEBrowser.sln file and try

Form showing nothing. using CefSharp with Windows form in C#

I am trying to show a webpage in a form using C#. I am using CefSharp to show the webpage (as I would like to test & learn how it works). But since I have worked only on inbuilt webbrowser, I have no idea how to get started with CefSharp(Finding it difficult to get any tutorials). I tried to write this code which executes but the form shows nothing in it. Where am I going wrong ?
Here is my Code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
namespace chrometest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Cef.Initialize(new CefSettings());
var test = new CefSharp.WinForms.ChromiumWebBrowser("http://www.google.com")
{
Dock = DockStyle.Fill,
};
this.Controls.Add(test);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Edit :
I tried to run the example from https://github.com/cefsharp/CefSharp/tree/cefsharp/41/CefSharp.WinForms.Example
When I try to build the solution, it shows a dialog box saying "Restoring Nuget Package cef.redist.x64 3.2454.1317" with a progresss bar which takes hell lot of time to complete but never completes and after sometime it hangs.
Please help what should I do to get the example running.
The CefSharp project has a few different examples as part of the main project.
Basic Example using Nuget
https://github.com/cefsharp/CefSharp.MinimalExample
More Advanced Examples
https://github.com/cefsharp/CefSharp/tree/cefsharp/41/CefSharp.WinForms.Example
When you installed the project using Nuget it should have opened a Readme.txt file, it contains a lot of useful information.
https://github.com/cefsharp/CefSharp/blob/cefsharp/41/NuGet/Readme.txt
In the context of WinForms there's a few tutorials
http://www.codeguru.com/columns/dotnet/if-you-like-it-put-an-html5-ui-on-it.html
http://thechriskent.com/2014/08/18/embedded-chromium-in-winforms/
For those reading this looking for WPF, there's
http://www.codeproject.com/Articles/881315/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
http://www.codeproject.com/Articles/887148/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
More Links
https://github.com/cefsharp/CefSharp.Tutorial
http://thechriskent.com/category/net/cefsharp/

C#/SQL: 'System.Data.Objects.ObjectSet<DatabaseName.TableName> does not contain a definition for 'Local'

I am attempting to follow the example from Deitel's "C# 2012 for Programmers" from chapter 20 specifically around page 625. I've changed some of the names (my database is "pdxdevinv" instead of "BooksExamples" and my table is "hardwareidtable" rather than "Authors"). Also, I'm using Visual Studio 2010 rather than 2012 because it's what I already own. And I'm using MySQL 6.0.
The problem is that the line:
hardwareidtableBindingSource.DataSource = dbcontext.hardwareidtables.Local;
Produces this error, complaining that hardwareidtables doesn't have a member named Local:
Error 1 'System.Data.Objects.ObjectSet' does not contain a definition for 'Local' and no extension method 'Local' accepting a first argument of type 'System.Data.Objects.ObjectSet' could be found (are you missing a using directive or an assembly reference?) C:\Users\swade\Documents\Visual Studio 2010\Projects\InventoryTracker\DisplayTable\DisplayHardwareTable.cs 38 82 DisplayTable
Here's the whole source file:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Validation;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DisplayTable
{
public partial class DisplayHardwareTable : Form
{
public DisplayHardwareTable()
{
InitializeComponent();
}
// Entity framework DbContext
private InventoryTracker.pdxdevinvEntities dbcontext
= new InventoryTracker.pdxdevinvEntities();
private void DisplayHardwareTable_Load(object sender, EventArgs e)
{
// load hardwareidtables table ordered by manufacturer and then hardwareId
dbcontext.hardwareidtables
.OrderBy(h => h.manufacturer)
.ThenBy(h => h.hardwareId)
.Load();
// THIS IS THE PROBLEMATIC LINE BELOW
// specify DataSource
hardwareidtableBindingSource.DataSource = dbcontext.hardwareidtables.Local; // .Local????
}
private void hardwareidtableBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
Validate();
hardwareidtableBindingSource.EndEdit();
try
{
int ret = dbcontext.SaveChanges();
}
catch (DbEntityValidationException)
{
MessageBox.Show("Validation of entered fields failed", "Entity Valid Exception");
}
}
}
}
If I remove ".Local" from that line, it builds and runs but will not save any data when the "save" button is clicked.
To start off with, the error is stemming from the Local property not found on the DbSet. Now there could be many reasons for this. This has been discussed here.
Why can I not see the property Local when using Entity Framework?
If this is does not help, please post your EF version and so we can investigate further.
Cheers.
In the end I decided to completely abandon the use of the Entity Framework. I was never able to get it to use DbContext rather than ObjectContext. I simply fell back to DataSets which are working fine albeit not ideal.
Lesson learned: Unless you have a dire need to use EF for database connectivity, avoid it. It is too complex and temperamental for casual use.

linking a new windows form with an existing project in c#

I have a c# problem. I have created a project called 'classproject' and I have added several forms to project successfully and successfully ran the program, but there is this other windows form that I just added and when I double-clicked on the form, it took me to the code view and brought out this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class demo : Form
{
public demo()
{
InitializeComponent();
}
private void demo_Load(object sender, EventArgs e)
{
}
}
}
Now, my challenge is that the name of the project is meant to show by default after the namespace as in "namespace classproject" instead of "namespace WindowsFormsApplication1". Please can anyone help me out, what am I meant to do because have tried everything possible. Even if I change the name myself its still going to flag error... someone please help me as soon as possible.
I'm not sure exactly what your issue is. If you change the namespace manually in the code to classproject it should be fine. What error are you talking about? You would also need to change the designer code file as well (probably called demo.Designer.cs).
Just a side note as well. Standard naming convention for C# is to use Pascal-case (as in ClassProject).
You must change namespace in ALL files that was generated by Visual Studio. You can do it manually, or just set cursor on "WindowsFormsApplication1", press F2 and enter new name.
Optionaly you can also change namespace in project properties on Application tab - then all new files added to project will also have namespace that you set there.

Categories

Resources