Answered by:
Cannot reference dll in windows service

Question
-
Hi!
I've created a windows service in VS 2010 which references the model conveniently placed in a separate project which compiles to a dll. I have no problem referencing this dll in other parts of my solution (web apps), but in my windows services the following symptoms display:
- Compiler error: The type or namespace %%% cannot be found (are you missing....
- I add a reference to %%% (directly to a dll copy or to the project, makes no difference).
- The compile error disappears.
- I build.
- The compile error reappears.
Using fw4.
What's up with that?
Edit: I can add and use other dlls ofcourse. Third party and microsoft's.
Thursday, July 22, 2010 1:11 PM
Answers
-
I forgot to read the warnings.
C:\Windows\Microsoft.NET\Framework\v4.0.21006\Microsoft.Common.targets(1291,9):
warning MSB3253: The referenced assembly "Bar.dll" could not be resolved because it has a dependency on
"System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client".Solution: http://stackoverflow.com/questions/1987733/system-web-extensions-assembly-cannot-be-resolved
Thank you everyone for your help!
- Marked as answer by SamAgain Friday, July 30, 2010 7:33 AM
Sunday, July 25, 2010 2:56 PM
All replies
-
Hi Camitz
How have you added this DLL to your project?
You have to use Add Dll reference option at the references project folder.
Instead of the right attempts have you taking this errors i suggest to control your namespaces
Good Lucks
Hamit YILDIRIMSaturday, July 24, 2010 9:20 AM -
Thanks for your reply.
Using Add references, I've tried both the browse tab and the project tab. I didn't quite understand your last sentence. I have used completely separate namepaces in the dll-project and the service. I've tried setting up the projects from scratch in different solutions. Nothing works.
best
Martin
Saturday, July 24, 2010 10:22 AM -
Hımm oke
i am thinking, i fully understand your semptom
1- It did not find a namespace which you have used in your code stream
Solution:
- You have to define using directive where this message insisted from
- You may find by recompiling the project
- Through the compression of this separate file's using directives maybe helpful for identifying the error.
Good lucks..
Hamit YILDIRIMSaturday, July 24, 2010 10:51 AM -
Suggestion 1: The odd behavior may be related to circular references. Try creating a dependency graph (under the menu Architecture/Generate Dependency Graph)
Suggestion 2: Make sure your solution has the correct compile order. In solution properties look at the project dependencies.
Suggestion 3: In solution properties / configuration, are all projects being compiled?
Suggestion 4: Do a "Clean Solution".
If none of these suggestions help maybe you can post more details.
Saturday, July 24, 2010 11:40 AM -
Thank's for your replies!
@Hamit, that's already been done. Recompiling 1000's of times. The problem is more obscure.
@Johan, good suggestion with the dependency graph. I downloaded NDepend and produced a dependency graph of the solution, minus the service. The were no cycles. Since nothing in the project depends on the service, the addition of the service in the graph should produce no cycles.
Furthermore, the compile order is correct, all projects compile. I also performed a clean solution.
Is there any particular way the namespaces should be named within a solution?
Unloading all other projects from the solution I have on the service and the dll project. The service depends on the dll according the "project dependencies". All other references are System.* or Microsoft.*.
It doesn't work on any other computers. I've tried referencing and using other dlls, that works. I've tried another dummy dll I made myself. That didn't work. I'm baffled.
I'm using VS2010, everything is fw4.0. C#.
What other details can I provide?
best
Martin
Sunday, July 25, 2010 11:50 AM -
I forgot to read the warnings.
C:\Windows\Microsoft.NET\Framework\v4.0.21006\Microsoft.Common.targets(1291,9):
warning MSB3253: The referenced assembly "Bar.dll" could not be resolved because it has a dependency on
"System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client".Solution: http://stackoverflow.com/questions/1987733/system-web-extensions-assembly-cannot-be-resolved
Thank you everyone for your help!
- Marked as answer by SamAgain Friday, July 30, 2010 7:33 AM
Sunday, July 25, 2010 2:56 PM -
I know its bit late to reply... But I think I know what is the problem with your windows service not able to recognize your model...
Every window service project, by default targets to .netClient version (which is not full version of .net and does not include the System.Web etc. This is atleast true with VS 2010) and the solution is to go to the project properties of Windows service and update the target frame work to .netFramework 4, instead of .net framework 4 client profile that should make your windows service to recognize your model project...
- Proposed as answer by Kevdevman Friday, February 25, 2011 4:15 PM
Saturday, September 25, 2010 6:21 PM -
Thank You Pakkuri, i had a problem similar to what is reported above, and your post has fixed it all.
Thanks,
Hanan
CISMonday, November 15, 2010 8:57 AM -
Thanks Pakkuri,
Fixed my issue also!
K
Friday, February 25, 2011 4:16 PM -
I know its bit late to reply... But I think I know what is the problem with your windows service not able to recognize your model...
Every window service project, by default targets to .netClient version (which is not full version of .net and does not include the System.Web etc. This is atleast true with VS 2010) and the solution is to go to the project properties of Windows service and update the target frame work to .netFramework 4, instead of .net framework 4 client profile that should make your windows service to recognize your model project...
The VipXMonday, October 3, 2011 6:17 PM -
Thanks.
This post really saves my day.
Tuesday, May 15, 2012 2:35 PM -
Awsome, This post saved my day. Thanks Pujjuri.Thursday, May 24, 2012 4:06 PM
-
perfect answers... solved the same problem I was facing. great!!Friday, June 26, 2015 9:14 AM