Solved

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

Posted on 2006-06-12
14
283 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

12 Experts available now in Live!

Get 1:1 Help Now