Using a Reference in a Service

D

Derek Martin

I am creating a windows service and have added a reference to a DLL project
that I have created. That DLL file is correctly referenced in both a
windows app and a web app, all in the same solution, so I thought I could do
the same for a service project. However, after successfully adding the
reference and making sure the namespaces were correct, I cannot see any of
my public methods and functions from the DLL file.

Is there anything special that must be done to permit reference members to
be seen in a function? Thanks so much!

Derek
 
J

Jay B. Harlow [MVP - Outlook]

Derek,
A windows app, a web app & a windows service all "reference" a DLL project
in the same manner, what is visible to one, must be visible to the others.

It sounds like you have something else confused. As all four in the same
solution? Do the first three reference the DLL Project itself or the DLL
directly. I normally reference the DLL Project. Are you using VS.NET 2002,
VS.NET 2003 or the VS.NET 2005 beta?

I have a number of Windows Services that reference DLL projects within the
same solution & haven't had any problems yet...

Hope this helps
Jay

Derek Martin said:
Do references in Windows Service applications just not work?
 
D

Derek Martin

Hey Jay, I reference the project. Using 2k3 version. Here's what I found
out...
The projects must be in different namespaces - doink. My windows app uses
the namespace clue, my web app uses the namespace clue, my dll project uses
the namespace clue, but my windows service cannot apparently use the
namespace clue. Once I changed the namespace in the windows service project
to something other than clue, it worked just fine...is that odd or what!?

Oh well,

Derek





Jay B. Harlow said:
Derek,
A windows app, a web app & a windows service all "reference" a DLL project
in the same manner, what is visible to one, must be visible to the others.

It sounds like you have something else confused. As all four in the same
solution? Do the first three reference the DLL Project itself or the DLL
directly. I normally reference the DLL Project. Are you using VS.NET 2002,
VS.NET 2003 or the VS.NET 2005 beta?

I have a number of Windows Services that reference DLL projects within the
same solution & haven't had any problems yet...

Hope this helps
Jay
 
J

Jay B. Harlow [MVP - Outlook]

Derek,
I normally set each project to a unique Namespace, that share a root
namespace.

Something like:
Windows App: MyCompany.Clue.Manager, MyCompany.Clue.UI or even
MyCompany.Clue.Manager.UI
Web App: MyCompany.Clue.Manager or MyCompany.Clue.UI
Windows Service: MyCompany.Clue.Service
DLL Project (domain/business objects): MyCompany.Clue.Domain or even
just MyCompany.Clue
DLL Project (data objects): MyCompany.Clue.Data
DLL Project (utility objects): MyCompany.Clue.Framework or even just
MyCompany.Clue (if there are not domain/business objects).

Having the namespace the same, should not matter (as evidenced by the DLL &
windows app working). I suspect you have something else going on:
- Do you have a class named the same as a namespace? Such as the Service
itself (the class that inherits from ServiceBase) is called Clue? You should
avoid naming classes & namespaces the same, especially when they are nested,
as this causes ambiguities for the compiler.

- Do you include the Namespace statements in one project, while the other
projects do not? I normally set the root namespace for the Project (as
identified above) in the Project Properties, then I use Namespace statements
when I have a group of types in that project that I want to be qualified.

- Something else?

Note I modified one of my projects so the Windows Service root namespace
matches a referenced DLL Project's root namespace. It finds all the needed
classes...

Hope this helps
Jay
 
D

Derek Martin

Ambiguousness appears to be what I had - I have since gone through as you
suggested and set up a root namespace and drilled down from there in the
various classes, etc. That did it! Thank you so much!!!!!
:)

Derek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top