WCF service library project can't find reference to other project - c#

I have two projects in my solution: MyApp.Domain and MyApp.WebService. MyApp.WebService is a WCF service library.
I want to use some utility functions from MyApp.Domain. So in MyApp.WebService, I added a reference to MyApp.Domain.
Intellisense picked it up just fine, it recognized the function I need to call. But when I build the solution, I get this error:
The type or namespace name 'Domain' does not exist in the namespace 'MyApp' (are you missing an assembly reference?)
at using MyApp.Domain.Utility;
What's going wrong here?

Make sure both are using the same profile... if one is using the client profile you could be getting this error.... also if the referenced assembly has some references in it to other assemblies you may need to include them in the project as well. If that doesn't get it make sure both have the same setting for 32 vs 64 bit...
GL

Remove WCF Service project from Solution and build solution. After building solution, add WCF project again. Issue will be resolved.

Related

The type or namespace name 'Core' does not exist in the namespace

I encounter this kind of error when I debug a project
I already have EntityFramework.dll, System.Core.dll, System.Data.Entity but still Core is not referenced.
Can someone help me?
I'm having error in this Line
using System.Data.Entity.Core.Objects;
This is the error:
The type or namespace name 'Core' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)
Enrique, I had this problem crop up when I started opening a project on my desktop that I had normally been opening on my VM. Masoud's answer is not helpful... I don't think he read your original post.
What I did to clear this compile error up was to open NuGet package manager and install the update that was available for EntityFramework. I had version 6.1.1 installed in the project and I upgraded to 6.1.3. I should not have had the error to start with, but upgrading the version appeared to jiggle whatever it was loose because I started compiling fine after that.
Sometimes, when you add references from other sources than nuget manager (example: Local source) you need to verify the HintPath of that reference before moving your application in another environment

SGEN.exe - Microsoft.Xml namespace not found

I have a strange issue with my generated serialization .dll. The .dll is successfully generated I can reference it in my project, all the types are contained within the namespace Microsoft.Xml.Serialization.GeneratedAssembly as expected, even the intellisense is picking up the types and namespaces. But when I go to build the project referencing any of the types within the generated assembly I get an error along the lines of:
Error 2 The type or namespace name 'Xml' does not exist in the
namespace 'Microsoft' (are you missing an assembly reference?)
Rather odd, no? The namespace clearly exists as far as intellisense is concerned and I've never had an issue like this before. I tried to regenerate the assembly, still the same problem.
For now I have run sgen.exe with the flag /keep and just copied the generated source into my project which is fine. I was just curious if there was a way to fix this issue or if anyone else has ever come across it before.
EDIT:
It turns out that the issue is because the generated assembly is targeting a version of the .NET framework greater than the assembly that is referencing it. Now the question becomes - how do I generate a serialization assembly with Sgen that targets a specific .NET framework version.
Ok so after reading the answer on this question I managed to generate a serialization assembly that has the correct "runtime version" for .NET 3.5 and everything works as expected, sorry for wasting time.

Webservice reference cannot find assembly reference

I have a c# project with a reference that cannot be found when checking in to TFS. The project runs fine when i debug.
It its in my services project the problem is located. I have a reference to lets say ProjectSec. And i have a wewbservice reference to Projectservice.
The webservice uses the ProjectSecurity.Security namespace that is located in the ProcectSec assembly.
When i check in my files i get the following error:
The type or namespace name 'ProjectSecurity' could not be found (are you missing a using directive or an assembly reference?)
Could not resolve this reference. Could not locate the assembly "ProjectSec". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
The ProjectSec.dll is located in the lib folder and its there. There is no error when i try to use it elsewhere in my project.
This may not be a perfect explanation but does anyone know what i could try?
I have removed the reference and added it over again, but no luck.
A common pitfall with TFS-build is to have in Source Control something, for example, like this:
$/Sources/Webservice
$/Libs/ProjectSecurity
And then, in the build definition that is validating your checkin, to have only
Active | $/Sources/Webservice | $(SourceDir)
as workspace mappings.(You can access this by right-clicking on the build definition in TeamExplorer, select "Edit Build Definition.." & go to Tab "Workspace")

Missing reference

In project i have reference to Microsoft.Office.Word.Server
and in code i have method that takes argument of type ConversionJob, but when i try to compile it i have an errors
The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
The type or namespace name 'ConversionJob' could not be found (are you missing a using directive or an assembly reference?)
but when a press f12 on ConversionJob it tooks me to the class defenition
using Microsoft.Office.Word.Server.Service;
using Microsoft.SharePoint;
using System;
namespace Microsoft.Office.Word.Server.Conversions
{
public class ConversionJob
{
public ConversionJob(WordServiceApplicationProxy serviceApplicationProxy, ConversionJobSettings settings);
public ConversionJob(WordServiceApplicationProxy serviceApplicationProxy);
...
what is wrong?
target framework is .Net framework 3.5
Solution
Ive solve the problem. I look to the output and there was message:
Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "<assembly reference>" could not be resolved because it has an indirect dependency on the framework assembly "<assembly" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5". To resolve this problem, either remove the reference "<assembly>" or retarget your application to a framework version which contains "<assembly>"
i try to find solution in google and - > http://www.sanderstechnology.com/2011/warning-msb3268-you-are-about-to-experience-pain/10646/#.TtYrXGP20Z8
Check the target framework of your application, might be you´re building for the client profile but the referenced assembly requires the full framework.
Try changing the "Target Framework" to be ".NET Framework 4" instead of ".NET Framework 4 Client Profile".
Project Properties -> Application Tab -> Target Framework
You likely need to delete (MAKE SURE TO BACK IT UP) the 12.x.x.x .dll in your GAC folder, and make sure you are referencing the 14.x.x.x in your solution.
If you look at the project references, is it finding the assembly? The icon will look different if it can't resolve it.
1.Try to delete and then manualy add the reference (sometimes it helps - VS losting needed dll but not show it with another sign if not clean)
if 1. ok then backup and try to remove from GAC folder (to understatnd from where it calls assembly)
Probably you have a namespace or class with the name Office somewhere in your code. The compiler uses your namespace instead Office.
In other words I think you have a name collision with your project or any of the references you have in it.
Please investigate for overlapping namespaces / classes.

This should not be happening. Outlook addin can't find assembly reference?? Why?

I can not work this out. I have a class library called 'ABC.Service'. In this class library I have referenced other projects from my solution.
In my 'ABC.Service' I have consistently named my classes namespace 'ABC.Service'.
I have made a project reference to this 'ABC.Service' and another class library called 'ABC.Entities' from a OutlookAddin project in the same solution.
For some reason the outlook addin project does not compile and outputs that 'The type or name 'Service' does not exist in the namespace 'ABC' (are you missing an assembly reference?) . However it does not complain about the 'ABC.Entities' classes???
The 'ABC.Service' compiles just fine and can be referenced successfully from a Windows project in the same solution which compiles just fine.
In the outlook addin intellisense can detect the namespace and class just fine also
I am obviously not missing the reference so the error message is so misleading.
I have tried;
Cleaning project/solution
Shutting down VS2010
Restarting Computer
I can only see 2 possible problems (which I can not understand why they would be problems)
In the 'ABC.Service' I have a
reference to
'Micorosoft.Office.Interop.Word'
assembly.Could this be doing
something?
I have some generated code with a
namespace called 'ABC.BusinessLogic'
instead of 'ABC.Service' - removing
this generated code to see if this is
the problem would be a nightmare as
much more would need to be changed to
get it to compile and I really don't
understand why it would be a problem
Has anyone got any ideas??
Any help appreciated
I've heard of this sort of thing happening when a project's build mode gets changed to "Client Profile." You might want to check on that.

Categories

Resources