Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Not finding a namespace

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
K Viltersten - 24 Mar 2008 14:49 GMT
I have a namespace Donkey in a project
called Donkey. In another project i
have created a WPF shell (exciting
stuff, by the way).

Now, i'd like to create an instance of
one of the classes in the Donkey as i
press a button. The code is like this.

 private void Execute_Click
   (object sender, RoutedEventArgs e) {
  Monkey monkey = Monkey (); }

Monkey is a class in Donkey, of course.

Since the compiler doesn't know about
Monkey (nor Donkey) i added:

 using Donkey;

but it just nags about references
missing and assemblies being incorrect.
So, i tried to add a reference to
Donkey in my WPF project but i don't
really see what to conenct to what.
Suggestions?

--
Regards
Konrad Viltersten
--------------------------------
sleep    - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Peter Duniho - 24 Mar 2008 17:56 GMT
> [...]
>    Monkey monkey = Monkey (); }

Even with your Donkey project correctly added as a reference to your shell  
project, and even with a correct "using" directive at the beginning of the  
file that includes this code, it won't compile because you've forgotten  
the "new" keyword.

Pete
K Viltersten - 24 Mar 2008 20:48 GMT
>> [...]
>>    Monkey monkey = Monkey (); }
[quoted text clipped - 3 lines]
>file that includes this code, it won't compile because you've forgotten
>the "new" keyword.

Besides that, of course. It's a typo.

What i've done is that i referenced an EXE file, which
in my (possibly ignorant) opinion is a strange thing to
do. Is it?

--
Regards
Konrad Viltersten
--------------------------------
sleep    - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Peter Duniho - 24 Mar 2008 20:56 GMT
>>> [...]
>>>    Monkey monkey = Monkey (); }
[quoted text clipped - 5 lines]
>
> Besides that, of course. It's a typo.

Well, it's the only thing in your original post that seemed wrong.

> What i've done is that i referenced an EXE file, which
> in my (possibly ignorant) opinion is a strange thing to
> do. Is it?

Yes, I'd say "strange".  But I don't know that it's not allowed.  There's  
not much difference between a DLL and an EXE, other than the way the OS  
loads them.  I don't know that those differences would lead to some  
compiler error.

That said, first thing you should probably try is changing the EXE project  
to be a DLL instead, then reference that DLL.

If that doesn't fix the problem, you'll need to be more specific about  
what's not working.  For best results, you need to come up with a  
concise-but-complete code sample that reliably demonstrates the problem.  
In this case, that probably means a pair of minimal projects, one that  
references the other.  Show us the projects, describe precisely how you're  
referencing one from the other (you should be adding one as a reference to  
the other, and if you want to use a class in that one without qualifying  
it, you'll have to add the namespace using directive in the other to  
support that).  And finally, and perhaps most importantly, be very  
specific about the error you're getting.  What line of the posted code  
causes the error and what is the _exact_ text of the error?

Pete
K Viltersten - 24 Mar 2008 21:48 GMT
>> What i've done is that i referenced an EXE file, which
>> in my (possibly ignorant) opinion is a strange thing to
[quoted text clipped - 4 lines]
>loads them.  I don't know that those differences would lead to some
>compiler error.

I was unclear, i think. I _GOT_ it to work. No apparent
errors there. My problem is that i fear that i did
something seemingly working but going to bite me in
the lower back later on, since i didn't use DLL, only
EXE. So, if you can't see anything wrong with making
the program run _THAT_ way, we have no problem.   :)

Thanks and sorry for not being clear.

--
Regards
Konrad Viltersten
--------------------------------
sleep    - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Jon Skeet [C# MVP] - 24 Mar 2008 22:47 GMT
<snip>

> I was unclear, i think. I _GOT_ it to work. No apparent
> errors there. My problem is that i fear that i did
> something seemingly working but going to bite me in
> the lower back later on, since i didn't use DLL, only
> EXE. So, if you can't see anything wrong with making
> the program run _THAT_ way, we have no problem.   :)

Adding a reference to an executable is fine, in my view. Aside from
anything else, it's the only way of writing unit tests against
executables, unless you make the executable *just* a single class which
immediately calls into a DLL.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Peter Duniho - 24 Mar 2008 23:50 GMT
> I was unclear, i think. I _GOT_ it to work.

Ah, okay.  No, I don't think you made that clear.  And yes, assuming it  
works, I don't see anything fundamentally wrong with referencing an EXE.

Sounds like you're "good to go!" :)

Pete

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.