The type or namespace name 'MicroKernel' does not exist in the namespace 'Castle' (are you missing an assembly reference?)
I'm new to castle w开发者_Python百科indsor and wanted to learn it.
I downloaded Windsor 2.5.3 for .net4 from here http://www.castleproject.org/castle/download.html
I built my first console app using vs2010 and try to play around.
The following are my code(very simple)
using Castle.Windsor;
using Castle.MicroKernel.Registration;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
WindsorContainer wc = new WindsorContainer();
wc.Register(Component.For<I>().ImplementedBy<C>());
var v = wc.Resolve<I>();
var result = v.M();
}
}
public class C : I
{
public string P1 { get; set; }
public int M()
{
return 100;
}
}
public interface I
{
int M();
}
}
But it didn't get compiled, error msg says:
The type or namespace name 'MicroKernel' does not exist in the namespace 'Castle' (are you missing an assembly reference?)
The type or namespace name 'Windsor' does not exist in the namespace 'Castle' (are you missing an assembly reference?)
I actually referenced castle.core and castle.windsor dlls and intellisense was working fine until compile....
I also noticed that when I double click the castle.windsor in reference, it's not showing the namespace hierarchy in object browser window.
I even commented out all my code, it still can't compile, says the same error msg.
Can you please advise what can I do to make it run. really appreciate it!!
The problem is likely the target framework of your project.
Open project properties, and look for the target framework dropdown. If it says .Net Framework 4.0 Client Profile, change it to .Net Framework 4.0.
精彩评论