using your own class library

C

Christopher Pisz

My C# book seems to leave out how to "link" to a class library I created.

I made a project of type class library called "Data Objects" and a project
of type windows application called "Economic Simulation" in the same
solution. Now I want to make use of one of the classes from "Data Objects"
called "Good", which is in Good.cs, in "Economic Simulation".

How do I perform the C++ equivalent of linking in C#?
 
P

Peter Duniho

My C# book seems to leave out how to "link" to a class library I created.

I made a project of type class library called "Data Objects" and a
project
of type windows application called "Economic Simulation" in the same
solution. Now I want to make use of one of the classes from "Data
Objects"
called "Good", which is in Good.cs, in "Economic Simulation".

How do I perform the C++ equivalent of linking in C#?

You need to add your library's assembly to the references of the project
in which you want to use it. In the Solution Explorer, right-click on
"References", choose "Add..." and find your project in the "Projects" tab
in the dialog. It should be there automatically, but if not my
recollection is that there's a button that lets you look for it.

Pete
 
R

Roger Frost

Peter Duniho said:
You need to add your library's assembly to the references of the project
in which you want to use it. In the Solution Explorer, right-click on
"References", choose "Add..." and find your project in the "Projects" tab
in the dialog. It should be there automatically, but if not my
recollection is that there's a button that lets you look for it.

Pete

Sort of related to your question and sort of not, but....

For simplicity's sake, you can also add a using statement for the namespace
of your library, if different than the project you working on. Note that
"using" and "referencing" are independent of each other.

So if you include a "using Foo.Bar;" statement at the top of your .cs
file...

you can type MyClass

....rather than Foo.Bar.MyClass

....and intellisense gets it.
 
C

Christopher Van Kirk

the using statement doesn't work unless you have a reference to the dll or
project in your project.
 
R

Roger Frost

Good call Christopher. Independent was the wrong word. I assumed Peter's
steps would have been taken prior to adding the using statement.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top