I am a new programmer of C#.net I've been working on a project already have 6 to 7 forms in it on which I am working, last night when I add new form and try to access directly to this form in program.cs file then neither there is frmForm1 suggestion is coming and if I write it manually then the error arise
Error 2 , The type or namespace name 'frmForm2' could not be found
(are you missing a using directive or an assembly
reference?) C:\Users\Ahsan\Desktop\SurveyBuilder\SurveyBuilder\Program.cs 29 37 SurveyBuilder
Whenever there is a form named Form2.cs is in my project, tried to attach snap of it but due to low reputation(its my first question on this site) I am not able to attach.
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 SurveyBuilder
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
}
}
Related
The first project is Class Library.
I can't just run it so i added a winforms project so i can use the Library methods and classes so i can debug the Library project.
But i can't get to the Lubrary project form the winforms.
In the winforms:
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;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
}
}
}
And the Library project name is AviFile and inside it there are classes.
When i type in the timer tick event AviFile it's not exist.
You need to add reference to your class library project named AviFile in your winform project by right clicking Reference -> Add reference -> Select Project -> choose the dll and select OK.
Then in your Form class import the namespace saying using AviFile;
See MSDN Documentation on how to do that.
Im trying to use LINQ in my ASP.NET/C# website. For that I need to access the class 'modelDataContext' which is a part of the LINQ namespace.
Im using Visual Studio 2010 Professional
This is my C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_new_feed : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
modelDataContext data = new modelDataContext();
}
}
Full error message I get
Error 1 The type or namespace name 'modelDataContext' could not be
found (are you missing a using directive or an assembly
reference?)
Things i've tried, which doesn't solve problem
Adding the reference (Right-click solution, add reference - System.Data.Linq)
Re-create the website
Right clicking on the line, to see if the tab "Resolve" was there. But it wasn't.
I was working through the MSDN tutorial for Crystal Reports, and I get to the Binding the Embedded Report to the CrystalReportViewer Control step:
When I try the build, it tells me that I am missing my using declaration for Hierarchical_Grouping class. This brings up two questions for me...
What is the namespace for this class definition?
Is there an easy way of determining the namespace of a given class?
In another answer I saw the 'ALT, SHIFT, F10' and the 'CTRL, [period]' suggestions for intellisense, but they don't work in my Visual Studio.
I'm sure I have done something ridiculously stupid....sorry in advance....
Here's the code for the form:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace CrystalTest3
{
public partial class Form1 : Form
{
private Hierarchical_Grouping hierarchicalGroupingReport;
public Form1()
{
InitializeComponent();
}
private void ConfigureCrystalReports()
{
hierarchicalGroupingReport = new Hierarchical_Grouping();
crystalReportViewer.ReportSource = hierarchicalGroupingReport;
}
private void Form1_Load(object sender, EventArgs e)
{
ConfigureCrystalReports();
}
}
}
I am assuming that you are referring to this tutorial.
The Hierarchical_Grouping seems to refer to the report file - which will contain the class named Hierarchical_Grouping. Have you added the report to your project?
The report should be somewhere in these Sample Reports Directories.
I keep on receiving this error message. I followed the instructions but it seems it is still not working? what is the solution for this? here's 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.Windows.Forms;
using System.Data.Linq;
using System.Data.Linq.Mapping;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MyDatabaseDataContext = new MyDatabaseDataContext(#"C:\Users\John\Documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\MyDatabase.mdf");
}
}
}
Here's the stacktrace
Error 1 'WindowsFormsApplication1.Form1' does not contain a definition for 'Form1_Load' and no extension method 'Form1_Load' accepting a first argument of type 'WindowsFormsApplication1.Form1' could be found (are you missing a using directive or an assembly reference?) C:\Users\John\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs 92 55 WindowsFormsApplication1
This happens if you add an event handler in the designer, then delete the handler method.
Since you didn't delete the auto-generated code that adds the method to the event, you get a compiler error.
Go to the .Designer.cs file and delete the line with the error.
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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 myform = new Form2();
myform.ShowDialog();
}
}
}
The following code should "launch" form2. They are in the same project, and have the same namespace. I don't understand. I have tried changing the .NET framework from version 4 client to version 4.
Any other ideas?
right click on Form2, chose "resolve" and pick one of the resolutions, alternatively move it to the WindowsFormsApplication3 namespace.
In my case I created form2, but renamed it later.
I found that although the name of the form changed, the name of the class remained as I originally created it.
For example:
1. Project->Add Windows Form (Setup.cs)
2. File->Save Setup.cs as... (frmSetup.cs)
3. Add code: frmSetup SetupForm = new frmSetup();
However, the actual name of the Setup class did not change with the file name, so changing my code to:
Setup SetupForm = new Setup();
So I was referencing the class name and not the file name solved the problem for me.
You can solve this issue in two wais:
You remove the namespace outside your form's class code or
Add a "using projectName" at the top of the code in your form.
Both forms should have the same namespace