473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use a class from one assembly into another

hello,

I want to create a class in a library:

public class GetHello
{
private string aa = "Hello world";
public GetHello()
{
//
// TODO: Add constructor logic here
//
}
public string GetContent()
{
return aa;
}
}

Then I create a simple project and I want to use the GetContent to return
the string.
What I did was to add a reference to the dll created by the library class,
from the Projects tab.
then I create an object:
MyData_Object myObj = new MyData_Object();

trying to use myObj, it does not see the method I created earlier:
GetContent

Thank you
Oct 11 '06 #1
6 1672
I forgot to mention:

namespace MyData_Object

{

}

"Daniela Roman" <da**********@rogers.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
hello,

I want to create a class in a library:

public class GetHello
{
private string aa = "Hello world";
public GetHello()
{
//
// TODO: Add constructor logic here
//
}
public string GetContent()
{
return aa;
}
}

Then I create a simple project and I want to use the GetContent to return
the string.
What I did was to add a reference to the dll created by the library
class, from the Projects tab.
then I create an object:
MyData_Object myObj = new MyData_Object();

trying to use myObj, it does not see the method I created earlier:
GetContent

Thank you


Oct 11 '06 #2
Daniela,
>public class GetHello
[...]
>MyData_Object myObj = new MyData_Object();

trying to use myObj, it does not see the method I created earlier:
GetContent
So is the class called GetHello or MyData_Object?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 11 '06 #3
Hello Daniela,

Have u pointed "using" statement with the namespace where your class locate?

DRI forgot to mention:
DR>
DRnamespace MyData_Object
DR>
DR{
DR>
DR}
DR>
DR"Daniela Roman" <da**********@rogers.comwrote in message
DRnews:%2****************@TK2MSFTNGP03.phx.gbl...
DR>
>hello,

I want to create a class in a library:

public class GetHello
{
private string aa = "Hello world";
public GetHello()
{
//
// TODO: Add constructor logic here
//
}
public string GetContent()
{
return aa;
}
}
Then I create a simple project and I want to use the GetContent to
return
the string.
What I did was to add a reference to the dll created by the library
class, from the Projects tab.
then I create an object:
MyData_Object myObj = new MyData_Object();
trying to use myObj, it does not see the method I created earlier:
GetContent

Thank you
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Oct 11 '06 #4
>MyData_Object myObj = new MyData_Object();
>>

You can only create an object of a class, not a namespace.

J.W.

Daniela Roman wrote:
I forgot to mention:

namespace MyData_Object

{

}

"Daniela Roman" <da**********@rogers.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>hello,

I want to create a class in a library:

public class GetHello
{
private string aa = "Hello world";
public GetHello()
{
//
// TODO: Add constructor logic here
//
}
public string GetContent()
{
return aa;
}
}

Then I create a simple project and I want to use the GetContent to return
the string.
What I did was to add a reference to the dll created by the library
class, from the Projects tab.
then I create an object:
MyData_Object myObj = new MyData_Object();

>trying to use myObj, it does not see the method I created earlier:
GetContent

Thank you


Oct 11 '06 #5
Thanks
I got the problem, I need to use the namespace in the USING reference and
then the class will be seen entirely.
Is this the approach in N-tier architecture? I mean to create each layer in
a library and then make references to them?

Thank you
Oct 11 '06 #6
What you need to do is to include the *Project* for the class library in the
Solution for any application that wants to use it. You can include a project
in as many Solutions as you like. I have a single class library Project that
is included in every Solution that I have written. After including the
Project in the Solution, create a reference to the *Project* in the other
Project. Visual Studio will manage the rest.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Daniela Roman" <da**********@rogers.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
hello,

I want to create a class in a library:

public class GetHello
{
private string aa = "Hello world";
public GetHello()
{
//
// TODO: Add constructor logic here
//
}
public string GetContent()
{
return aa;
}
}

Then I create a simple project and I want to use the GetContent to return
the string.
What I did was to add a reference to the dll created by the library
class, from the Projects tab.
then I create an object:
MyData_Object myObj = new MyData_Object();

trying to use myObj, it does not see the method I created earlier:
GetContent

Thank you


Oct 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2179
by: Edward Diener | last post by:
This has occurred in MC++, but since there is very little response on that NG, I am also reporting it here in the hope that someone can find me a workaround, and report it to MS. If a __value...
0
1620
by: keith | last post by:
I created a custom control class which inherted from another control class in C#. The another control referenced another assembly. I put the custom control into toolbox and drew it into a form...
3
3043
by: glenn | last post by:
I am assuming that Microsoft has renamed their (dll's) and are now calling them class libraries since I can't find anything related to dll's in Visual Studio. If I am correct in this assumption...
14
1942
by: Lee Franke | last post by:
I can't seem to figure this one out. Here is my class structure namespace name { public class foo { } }
0
1182
by: Edward Diener | last post by:
If a __value class with an event is put into an assembly, and a __gc class in another assembly attempts to attach its own event handler to the __value class's event of an embedded object of the...
6
1393
by: Dave | last post by:
We have developed a few .NET components. The application access these components through well defined interface IOurInterface. The application list display name of each component in the dialog,...
0
4216
by: Nonee | last post by:
Anyone, anyone? : ) Hello- I have a form with the mediaplayer referenced to play mp3's and avi's and I believe that is what is causing the problem. I am not sure, but I am hoping. ...
18
6484
by: Peter Gummer | last post by:
This is a design question. I have a project containing a dozen or so classes with protected internal constructors. My reason for having protected internal constructors is to prevent classes...
2
1668
by: tony | last post by:
Hello! I'm trying to build a class library which has a class called AvestaPlantFunc. In this project building a class libray exist a class called AvestaPlantFunc. In this class is there a...
3
2268
by: nadeem_far | last post by:
Hello All, I have a couple of questions and I am not able to find them any where on internet. 1. We are using a third party class library which exposes a class with the name of "class". ...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
Oralloy
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,...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5625
agi2029
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,...
1
5049
isladogs
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...
0
3192
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.