无法使用 ImportMany 属性进行编译
对于 MEF 新手来说,我在第一次测试 MEF 时遇到了问题。我的问题代码如下-
using System;
using GlobalInterfaces;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
namespace GlobalInterfacesUnitTest
{
[TestClass]
public class GlobalInterfacesUnitTest
{
[TestMethod]
public void TestMethod1()
{
[ImportMany(AllowRecomposition = true)]
Lazy<IComponentGui, IImportComponentGuiCapabilites>[] Senders {get;set;}
}
}
}
我无法让编译器找到“ImportMany”属性的问题。我已经检查了几个演示的参考文献并复制了它们的参考文献,但仍然存在同样的问题。我看不到我所忽略的东西。我使用的是VS2010/Net4.0。
As to total MEF newbie, I'm having a problem with my first test of MEF. My problem code is below-
using System;
using GlobalInterfaces;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
namespace GlobalInterfacesUnitTest
{
[TestClass]
public class GlobalInterfacesUnitTest
{
[TestMethod]
public void TestMethod1()
{
[ImportMany(AllowRecomposition = true)]
Lazy<IComponentGui, IImportComponentGuiCapabilites>[] Senders {get;set;}
}
}
}
The problem that I cannot get the compiler to find "ImportMany" attribute. I've checked the references against several demos and copied their references and still have the same problem. I cannot see what I'm overlooking. I am using VS2010 / Net4.0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在方法内定义属性。把它搬到课堂上。尝试:
You can't define properties inside method. Move it out to class. Try: