Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project,
which includes a class. I have added the project to the main application but
I can't seem to create an instance of the class in the main application. The
class is called MyFirstClass, with namespace MyFirstClass. What steps do I
need to take to create an instance of the class within the main windows
application?
Thanks in advance
Geoff 10 1155
You can change the namespace of your class to correspond with the namespace
of your other project so both assemblies become of one namespace.
Then, if you use myClass classOfMine = new myClass(); it should work.
"Geoff Jones" wrote: Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
Make sure your namespaces in both files match up. If not then you will have to
use the fully qualified name.
When you say "I have added the project to the main application" I'll assume you
meant "I have added the class to the main application".
If they are two different projects then you'll need to add a reference from one
to the other.
Try
MyFirstClass.My FirstClass instance = new MyFirstClass.My FirstClass();
- john
Geoff Jones <no********@ema il.com> wrote: Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
I get the message:
; expected
?
Geoff
"Vincent" <Vi*****@discus sions.microsoft .com> wrote in message
news:64******** *************** ***********@mic rosoft.com... You can change the namespace of your class to correspond with the namespace of your other project so both assemblies become of one namespace. Then, if you use myClass classOfMine = new myClass(); it should work.
"Geoff Jones" wrote:
Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
Hi John
This is very puzzling.
They are two different projects. I have now added a reference to the main
application for the other class. I have tried your suggestion and used the
fully qualified name but I still get the same error i.e. ; expected.
Geoff
<co******@tetra .xionheights.ne t> wrote in message
news:T%******** *******@fe37.us enetserver.com. .. Make sure your namespaces in both files match up. If not then you will have to use the fully qualified name.
When you say "I have added the project to the main application" I'll assume you meant "I have added the class to the main application".
If they are two different projects then you'll need to add a reference from one to the other.
Try MyFirstClass.My FirstClass instance = new MyFirstClass.My FirstClass();
- john
Geoff Jones <no********@ema il.com> wrote: Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
If you use Visual Studio you can double click the message and it will go to
where this error is located. You can then adjust it. (You probably forgot to
enter a ";" somewhere, where it was expected.)
For instance
myClass cls = new myClass() // will generate an error
myClass cls = new myClass(); // won't generate that error
"Geoff Jones" wrote: I get the message:
; expected
?
Geoff
"Vincent" <Vi*****@discus sions.microsoft .com> wrote in message news:64******** *************** ***********@mic rosoft.com... You can change the namespace of your class to correspond with the namespace of your other project so both assemblies become of one namespace. Then, if you use myClass classOfMine = new myClass(); it should work.
"Geoff Jones" wrote:
Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
Can you post a clip of your code? Maybe it's just a simple syntax error somewhere.
Geoff Jones <no********@ema il.com> wrote: Hi John
This is very puzzling.
They are two different projects. I have now added a reference to the main application for the other class. I have tried your suggestion and used the fully qualified name but I still get the same error i.e. ; expected.
Geoff
Hi Vincent
Yep, tried that. I've written
myClass cls = new myClass();
and it still gives the same error message.
Geoff
"Vincent" <Vi*****@discus sions.microsoft .com> wrote in message
news:04******** *************** ***********@mic rosoft.com... If you use Visual Studio you can double click the message and it will go to where this error is located. You can then adjust it. (You probably forgot to enter a ";" somewhere, where it was expected.) For instance myClass cls = new myClass() // will generate an error myClass cls = new myClass(); // won't generate that error
"Geoff Jones" wrote:
I get the message:
; expected
?
Geoff
"Vincent" <Vi*****@discus sions.microsoft .com> wrote in message news:64******** *************** ***********@mic rosoft.com... > You can change the namespace of your class to correspond with the > namespace > of your other project so both assemblies become of one namespace. > Then, if you use myClass classOfMine = new myClass(); it should work. > > "Geoff Jones" wrote: > >> Hiya >> >> I hope somebody can help me with this relatively simple beginner >> question: >> >> I have created a windows Application in C#. I have also created a >> project, >> which includes a class. I have added the project to the main >> application >> but >> I can't seem to create an instance of the class in the main >> application. >> The >> class is called MyFirstClass, with namespace MyFirstClass. What steps >> do >> I >> need to take to create an instance of the class within the main >> windows >> application? >> >> Thanks in advance >> >> Geoff >> >> >>
AHHHHHHHHHHHHHH HH!!!
Got it! I'd written
myClass cls = New myClass; // Note capital "N"
Strange, I would have thought the environment would allow both?
D'OH!
Thanks guys
"Vincent" <Vi*****@discus sions.microsoft .com> wrote in message
news:04******** *************** ***********@mic rosoft.com... If you use Visual Studio you can double click the message and it will go to where this error is located. You can then adjust it. (You probably forgot to enter a ";" somewhere, where it was expected.) For instance myClass cls = new myClass() // will generate an error myClass cls = new myClass(); // won't generate that error
"Geoff Jones" wrote:
I get the message:
; expected
?
Geoff
"Vincent" <Vi*****@discus sions.microsoft .com> wrote in message news:64******** *************** ***********@mic rosoft.com... > You can change the namespace of your class to correspond with the > namespace > of your other project so both assemblies become of one namespace. > Then, if you use myClass classOfMine = new myClass(); it should work. > > "Geoff Jones" wrote: > >> Hiya >> >> I hope somebody can help me with this relatively simple beginner >> question: >> >> I have created a windows Application in C#. I have also created a >> project, >> which includes a class. I have added the project to the main >> application >> but >> I can't seem to create an instance of the class in the main >> application. >> The >> class is called MyFirstClass, with namespace MyFirstClass. What steps >> do >> I >> need to take to create an instance of the class within the main >> windows >> application? >> >> Thanks in advance >> >> Geoff >> >> >>
Geoff,
The first thing when you have added a project to your project which holds a
class libary is setting a reference to it with the references and than the
tab "projects". Than that extra project(s) should be showed there and you
can select it.
Than you can set an import to that (not necessary however easy)
I hope that this is what you are after.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hzgt9b |
last post by:
When adding my VB .NET solution (with two sub-projects) the folder structure
in VSS gets an extra level of folders...
For example, here's the structure of the solution on my C:\
....\mySolution\mySolution.sln
....\mySolution\myProject1\myProject1.vbproj
-- and --
....\mySolution\myProject2\myProject2.vbproj
But after adding the solution to VSS the structure looks like this:
|
by: Wysiwyg |
last post by:
Is there any way to add an embedded resource to a project without copying it
to the project's directory? I have shared resources and don't want each
project using the images, xml files, etc. to need to be updated with the
current copy before being built. I also don't want projects being built with
the old copy.
Thanks!
Bill
|
by: Simon Jefferies |
last post by:
Hello,
I am trying to add an item to a checked list box, like:
clbList.Items.add("Hello",true)
I get an error back:
Run-time exception thrown: System.ArgumentOutOfRangeException - Specified
argument was out of the range of valid values. Parameter name: '-1' is not a
|
by: UJ |
last post by:
I have a couple of files (type definitions, constants, ...) that I want to
use in multiple projects. How do I make it so that I have only one copy of
the file for multiple projects? If I do add existing to a project, it copies
the file to the project directory. I'd like to have a single directory
(called something like library) that has all the common source code in it
that then gets referenced from the projects.
TIA.
Jeffrey.
|
by: _DS |
last post by:
The two obvious methods for ref'ing assemblies are:
Add a reference and 'Browse' for the actual DLL
OR
Add existing project to the solution, then add a ref to 'Project'.
1: I'd like to find out what the latter method is doing.
I'm assuming that it makes sure that debug exe gets matched to
| |
by: sukeshchand |
last post by:
How to create an event object in a dll without adding the dll into the project
ie.; i use CreateObject() to create an instance of an object in a dll without adding the dll into the project. it is ok but my problem is this -- ?? How to Create an event inside the dll without adding it in to the project refference ??
|
by: =?Utf-8?B?TGVvbiBNYXluZQ==?= |
last post by:
In a database project in VS2005 (not a datadude project), I need to add about
3,000 stored procedure scripts to my 'Stored Procedures' folder. I've dropped
the scripts into the folder in my workspace, and I right-click the folder in
solution explorer and select 'Add Existing Item' and select all my scripts.
The app adds about 15 or so and then fails with a messagebox saying "The
operation could not be completed".
Someone else seems to...
|
by: damonreid |
last post by:
Access 2003
Microsoft Windows XP Pro
Hey,
I am currently pulling my hair out here.
I have a Form for adding new projects to a database, the only problem is that when I close the form it doesn't insert that information into the table. This is a major problem as it is suppose to use the information to populate several other tables with key information and open another form based on some of that information (in this case project number).
...
|
by: Jason |
last post by:
Hello,
I am trying to utilitze the AJAX Control toolkit in my asp.net project. I
have added a reference to AjaxControlToolkit.dll, and in my page, added
these lines of code:
<ajaxToolkit:ToolkitScriptManager runat="Server"
EnableScriptGlobalization="true" EnableScriptLocalization="true"
ID="ScriptManager1" />
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |