"You must add a reference to assembly PresentationFramework" -- but why?
I am really newbie to c# and VS2010. :-\
I have a "pure" Winforms application. Or at least I think so.
But suddenly (with the last changes to the source code) I have this error when build an auxiliary DLL:
Error 7
The type 'System.Windows.Interop.HwndHost' is defined in an assembly that is not referenced. You must add a reference to assembly 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. D:\MyprojectPath\SharedExceptions.cs AuxLibraryProject
I don't want to add PresentationFramework.dll to the project and even when I have tried to add it then a lot of other assemblies are required. :-(
I want to know WHERE is the guilty of this assembly requirement. I will be happy to blame some line on my source code but I cannot find it.
The SharedExceptions.cs
is one of the files changed but when I (manually) delete all changes, the error persists.
This same assembly compiles fine on a Windows XP Visual Studio 2010 system. But not on Windows Vista.
Update:
I have left alone the parent exception for all others. All other are on other files. After rebuild, the error remains on the same file. Here is the little source code. I cannot see anything requiring the new assembly:
using System;开发者_运维知识库
namespace PROJECT.AuxLibraryProject
{
public class SharedExceptionParent: Exception
{
public string ErrorMessage
{
get
{
return base.Messsage.ToString();
}
}
public SharedExceptionParent() { }
public SharedExceptionParent(string errorMessage) : base(errorMessage) { }
public SharedExceptionParent(string errorMessage, Exception innerEx) : base(errorMessage, innerEx) { }
}
}
I have found it:
This line on top of namespace keyword on two assemblies was the culprit:
[assembly: CLSCompliant(true)]
I have deleted this line on both assemblies and all builds fine now.
Greetings.
You are either referencing HwndHost
, or something you added is referencing HwndHost
. This is defined in PresentationFramework.dll.
You'll need to track down the culprit. It's in your SharedExceptions.cs
file. There is obviously at least one change that didn't get backed out completely in that file.
(This, btw, is one huge advantage of using one file per class... I'm guessing that you have MANY exception types defined in that file, which is why you're not just seeing this instantly.)
精彩评论