Solved

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

Posted on 2006-06-12
14
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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