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

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!
Sandy WestmanIntegrations ConsultantAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
solublefishConnect With a Mentor Commented:
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
 
neilpriceConnect With a Mentor Commented:
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
 
Sandy WestmanIntegrations ConsultantAuthor Commented:
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
neilpriceCommented:
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
 
Sandy WestmanIntegrations ConsultantAuthor Commented:
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
 
neilpriceCommented:
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
 
Sandy WestmanIntegrations ConsultantAuthor Commented:
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
 
neilpriceCommented:
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
 
Sandy WestmanIntegrations ConsultantAuthor Commented:
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
 
neilpriceCommented:
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
 
Sandy WestmanIntegrations ConsultantAuthor Commented:
Deleted it and rebuilt.  Same problem.

Several public classes:

    public class OrderCreateType {
0
 
neilpriceCommented:
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
 
Sandy WestmanIntegrations ConsultantAuthor Commented:
That's it.  Thanks guys!
0
 
neilpriceCommented:
Ahhh I see the problem...  using .NET 2.0 Framework I can reference .exe's.

I should've spotted that sorry!

Neil
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.