Not Able To Initiate a Class in Main Coding - c#

i trying to call a form as show dialog in in main coding
i have added below screen shot to help you guys under what i am asking. I have tried search on the internet but wasn't able to find a solution too.
but itemsDeleteScreen,itemsEditScreen and AddScreens works perfectly
image screenshot - http://i.stack.imgur.com/E66du.png
the items DeleteScreen Code : (Which Works)
itemsDeleteScreen deleteItem = new itemsDeleteScreen();
deleteItem.ShowDialog(this); // loads the Delete Items Screen
the StockInsScreen Code : (Whic Does not Work)
stockInsScreen stkIns = new stockInsScreen();
stockInsScreen.ShowDialog(this);
the error which i getting when i compile is
The type or namespace name 'stockInsScreen' could not be found (are you missing a using directive or an assembly reference?)

Navigate to StockInScreen Class and check the namespace, it would be like(yourproject.foldername) and add that name space in the class you want to use.(Source:From Image you have provided).For information about namespace,look at http://msdn.microsoft.com/en-us/library/z2kcy19k.aspx

Related

Visual Studio don't recognize new Form Name/reference

I have a problems wit sencond Form when I want teo open it in the first one.
I do exactly like it is in this video:
https://www.youtube.com/watch?v=AIGoSsz5Wwo
Bu when I write: Form2 openForm = new Form2(); I get an error: The type or namespace name 'Form2' could not be found (are you missing a using directive or an assembly reference?)
I noticed that Form1 name also don't recognize.
I try to clean/rebuild, delete .vs, bon, obj folders but nothing happend
Do you have any idea where the problem is?
I would be happy any idea and solution,
DomenI
Form2 code
Form1 code
The problem is with namespace. What is the best way to changeit?
In the video, the form1 and form2 are in the same namespace "ButtonClickOpenNewForm".
But in your demo, they are in different namespaces, "NFCapp" and "Mg74App".
If you want to access the class in another namespace, you need to add reference to the namespace first by steps Project -> Add Reference....
Then call it through the full namespace.
Mg74App.Form2 form2 = new Mg74App.Form2();

Can't find linked class

I have two projects in the same solution and I have linked a class DatabaseFunctions.cs to the second one.
The problem is that when I reference it in the GUI_Teacher.cs I get the error:
Error CS0246 The type or namespace name 'DatabaseFunctions' could not be found (are you missing a using directive or an assembly reference?) Teachers application C:\Users\user1\source\repos\IASLSN\Teachers application\GUI_Teacher.cs
From the error, you are simply missing a reference.
Take the following steps to add a reference
Right click on the GUI_Teacher.cs project and click on Add Reference
From the left side of the Add Reference dialog, click on Solution
Select DatabaseFunctions.cs from the list and click OK to close the dialog.
In the source file DatabaseFunctions.cs you have something like
using System;
namespace SomeNamespaceName
{
public class DatabaseFunctions
{
}
}
To use the class in your GUI_Teacher.cs source file you need to add either using SomeNamespaceName; at the top or use the fully qualified type name SomeNamespaceName.DatabaseFunctions instead.
Keep in mind that the name of a sourcecode file like your DatabaseFunctions.cs for example has no connection to the name of a class or a namespace in that file. You can put a class like public class DatabaseFunctions { } in a file called foo.cs. And in the using directive at the top of your sourcefiles you provide a namespace and not a filename.

"The name does not exist in the namespace error" in XAML

I know this is a recurring error but I can't seem to get around it.
Intellisense does recognize the name of my custom control and suggests to add the proper using: directives, but not only XAML designer doesn't find the name of the control but I can't get through compilation either.
The custom control is a public class defined as
namespace MyApp.CustomControls
{
public class CustomTextBox : TexBox
{
...
}
}
And in my MainPage.xaml
<Page ...
xmlns:customControls="using:MyApp.CustomControls">
...
<customControls:CustomTextBox/>
...
</Page>
This does not render in design nor compile.
This answer and the ones below are not working for me.
The error message:
Error XDG0008 The name "CustomTextBox" does not exist in the namespace "using:MyApp.CustomControls".
Your code should works well after you build the project, and it works well in my side using your above code. Try to clean your solution or delete the bin and obj folders in your project then rebuild your app again. Also try to restart your Visual Studio. If it still happens, you can provide a reproducible sample to help me look into this issue.
I've seen quite a lot solutions saying that you should rebuild the project, restart Visual Studio or restart the machine.
What worked for me was specifying the assembly in the namespace reference, that is:
xmlns:the_namespace="clr-namespace:the_namespace" - produces the above error.
xmlns:the_namespace="clr-namespace:the_namespace;assembly=the_assembly" - works well.
I got a version of this error in my embedded UserControl when I tried to use the Name property in my XAML instead of using x:Name. In other words, when my XAML code looked like this:
myUserControls="using:MyUserControls"
<myUserControls:GraphCanvas Name="GraphCanvas" />
I got an error that 'The name "GraphCanvas" does not exist in the namespace "using:MyUserControls"'. When I changed one line of code to this:
<myUserControls:GraphCanvas x:Name="GraphCanvas" />
Everything built just fine.
I'm dropping this solution here because it took me about a day and a half to figure out this problem and this was the only stackoverflow page I found when I searched the error string. Hopefully I will save someone else the hassle I went through.

Why can Visual Studio detect which "using" is needed, but then say the type or class which provoked the addition of the reference does not exist?

On trying to build, all of a sudden (a couple of days since I worked on this project) I get:
"The type or namespace name 'IO' does not exist in the class or namespace 'OpenNETCF' (are you missing an assembly reference?)"
But when I comment out that line (using OpenNETCF.IO.Ports;), I get:
? OpenNETCF.IO.Ports.Handshake (multiple choices...)?
When I click that, the choices are two:
OpenNETCF.IO.Ports.Handshake
- and:
OpenNETCF.IO.Serial.Handshake
As the code in this unit deals with printing, I select "Ports" (rejecting "Serial" because of its yin/yanginess to "Parallel"). So it then adds back the using I had which it complained about (using OpenNETCF.IO.Ports)...and then it's back to the original err msg.
Yet I do have several OpenNETCF items in my References, namely:
OpenNETCF
OpenNETCF.Data
OpenNETCF.Drawing
OpenNETCF.Net
OpenNETCF.Phone
OpenNETCF.VisualBasic // I don't know why, this is a C# project
OpenNETCF.Web.Services2
OpenNETCF.Windows.Forms
OpenNETCF.WindowsCE.Forms
OpenNETCF.Xml
What could possibly cause this chicken-and-egg tail-chasing exercise in frustration?
Odder yet, I get, "The type or namespace name 'Windows' does not exist in the class or namespace 'OpenNETCF' (are you missing an assembly reference?)" pointing to this using in another .cs file:
using OpenNETCF.Windows.Forms;
...and yet that using is grayed out as being unused at any rate, but when I comment it out, I get a lot of other errors purportedly because it's gone, such as on this line:
IntPtr hwnd = OpenNETCF.Win32.Win32Window.GetCapture();
The type or namespace name 'Win32Window' does not exist in the class or namespace 'OpenNETCF.Win32' (are you missing an assembly reference?)
UPDATE
In another episode of "Well Flip My Bits!" I just now compiled, got those err msgs about not being able to reconcile this line of code with what is installed and configured, etc., scrolled up to see that the "using" it was supposedly missing was there, compiled again, and now it compiles fine. What the blue blazes?!?!?!?
This sounds like a problem you see when you are building a project for a "Client Profile" .net version while referencing assemblies that are not supported in client profile.
Try changing your project's build settings to use a .net framework version that is not "Client Profile".
One can use the namespace using inside class also, so consider moving it there, if there are classes that use both than use the full name as in OpenNETCF.IO.Ports.Handshake handshake = new OpenNETCF.IO.Ports.Handshake()
And for the class using namespace:
using System;
namespace MyNamespace
{
using OpenNETCF.IO.Ports;
//...
}

Dynamically adding usercontrol to placeholder

I'm having a brain freeze moment today. I must've done this many times but just can't work it out:
All i'm doing is running the following, but it's not saying releasestable is right.
Error 55 The type or namespace name 'releasestable' could not be found (are you missing a using directive or an assembly reference?) C:\Users\tomb\Documents\Visual Studio 2010\Projects\Findnzbs\Findnzbs\latestreleases.aspx.cs 16 11 Findnzbs
Heres the code:
releasestable webUserControl = (releasestable)Page.LoadControl("~/controls/releasestable.ascx");
webUserControl.listWhere = "myWhere";
phReleases.Controls.Add(webUserControl);
because you need to add it on the top of your code
like
using System.Collections;
using System.Data;
using Findnzbs.Controls;
is it
releasestable webUserControl (releasestable)Page.LoadControl("~/controls/releasestable.ascx");
webUserControl.listWhere = "myWhere";
or
releasestable webUserControl= (releasestable)Page.LoadControl("~/controls/releasestable.ascx");
webUserControl.listWhere = "myWhere";
Ok then the solution is add your namespace of the control.
example
if your application name is demoproject, then add
using demoproject.Controls;
where Controls is the folder were you have control code.
in your case it is Controls. so just copy paste the above line

Categories

Resources