Solved

Beginner question - How to use a namespace you defined in another project

Posted on 2006-06-12
14
281 Views
Last Modified: 2010-04-16
This is only my second project so I am probably missing something obvious.  I would appreciate it if you could give me steps to accomplish your recommendation in visual studio as I may not know how to, for example, add a reference if that's what I need to do.

I have a solution with three projects.  In one of the projects I define a namespace as follows

namespace BusinessMicrovar.IDIEDIWebClientConsole
{

In another project I want to use that namespace so I have the following code

using BusinessMicrovar.IDIEDIWebClientConsole;

When I build the project I receive the following error:

C:\Custom\IDI\IDIEDIWebClientConsole\BLIDIEDIWebClientConsole\BLBase.cs(2): The type or namespace name 'IDIEDIWebClientConsole' does not exist in the class or namespace 'BusinessMicrovar' (are you missing an assembly reference?)

I have checked under project>Project Dependencies and both projects are checked in this window.

Thanks!
0
Comment
Question by:sanw2020
  • 7
  • 6
14 Comments
 
LVL 6

Assisted Solution

by:neilprice
neilprice earned 200 total points
ID: 16890006
In the solution explorer find the item "References" in your project.

Right click and choose "Add Reference"

If the project is in the same solution you can choose to reference it from the "Projects" tab.

If it's not choose the "Browse" tab and browse to the compiled .dll or .exe that you have for that project (BusinessMicrovar.IDIEDIWebClientConsole)

Hope this helps,
Neil
0
 

Author Comment

by:sanw2020
ID: 16890077
OK,

I thought this was the problem, but when I had tried adding it I received the error that I must have a .dll to add a reference.  I've looked at my project folder and it does not have any .dll's.  I have built the project several times and I thought that was the process that created .dll's.  If not, how can I go about getting a .dll for my project to reference?

Thanks for the fast response.
0
 
LVL 6

Expert Comment

by:neilprice
ID: 16890087
Drill down in your project folder...

You should find a directory called "Bin" and then another inside that called "Debug" (or "Release" if you're building a release version)

The required dll should be in there.

Does that help?
Neil
0
 

Author Comment

by:sanw2020
ID: 16890127
This is where I expected the .dll to be located from previous projects I've done.  It is a Debug version.  I have looked in that folder and done a windows search in my entire solution folder and there are no .dll's for the projects I've created, just other .dll's I'm using.
0
 
LVL 6

Expert Comment

by:neilprice
ID: 16890162
You're sure you've already built the project you're trying to reference?

If so, try looking in the Build section of your project properties window for the project you're trying to reference.  There should be an output path listed - where the .dll will be created.

Any help?
Neil
0
 

Author Comment

by:sanw2020
ID: 16890251
Here are the results from the build

---------------------- Done ----------------------

    Build: 1 succeeded, 0 failed, 0 skipped

Here is my output path

bin\Debug\

Here is my project folder from the project properties

C:\Custom\IDI\IDIEDIWebClientConsole\

In that folder are the following files:

IDIEDIWebClientConsole.exe
IDIEDIWebClientConsole.exe.config
IDIEDIWebClientConsole.pdb
Interop.MSXML2.dll

Although the project is currently a Debug, it was set up as a release at one time.  Don't know if that's relevent info.

0
 
LVL 6

Expert Comment

by:neilprice
ID: 16890279
You have tried referencing the IDIEDIWebClientConsole.exe file?

I'm assuming you included the "using ..." line in each .cs file in the relevant project?

After adding the reference, when you type "using BusinessMicrovar." does it bring up an autocomplete box holding "IDIEDIWebClientConsole" ?

Thanks,
Neil
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:sanw2020
ID: 16890328
When I try to reference the .exe I receive "This is not a valid assembly or com reference".  

In my BLIDIEDIWebClientConsole project it brings up an autocomplete for

using BusinessMicrovar.BLIDIEDIWebClientConsole

But not the BusinessMicrovar.IDIEDIWebClientConsole which is defined in a different project.

Thanks again for all the time your spending on this question.
0
 
LVL 6

Expert Comment

by:neilprice
ID: 16890354
Try deleting the .exe already there and rebuilding it.

I'm not sure why it wouldn't be a valid assembly if it's building successfully.  There are public classes etc available in it yes?

Does that help?
0
 

Author Comment

by:sanw2020
ID: 16890401
Deleted it and rebuilt.  Same problem.

Several public classes:

    public class OrderCreateType {
0
 
LVL 6

Expert Comment

by:neilprice
ID: 16890514
Which version of the .NET framework are you using?
I'll try and spend some more time later this evening or early tomorrow working it out.

Neil
0
 
LVL 3

Accepted Solution

by:
solublefish earned 300 total points
ID: 16890544
You can't reference an .exe - you have to build your library as a DLL. Right-click your IDIEDIWebClientConsole project, choose properties. On the Common/General page, change "Output Type" to "Class Library".

Of course, if you have code in that library that needs to run as an .exe, you'll have to do a little more work:
- make a new DLL ("Class Library") project.
- move all of the shared classes (the ones that are needed by multiple other projects) to the new project.
- in each of the other projects, add a reference to the new project.



0
 

Author Comment

by:sanw2020
ID: 16890651
That's it.  Thanks guys!
0
 
LVL 6

Expert Comment

by:neilprice
ID: 16890656
Ahhh I see the problem...  using .NET 2.0 Framework I can reference .exe's.

I should've spotted that sorry!

Neil
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now