“可观察集合”该语言不支持
我使用 .NET 4 拼凑了一个 Windows 类库(称为 MPC_Core),我在 Windows Phone 7.1 应用程序中引用该类库。
我正在创建并初始化 ObservableCollection 对象(包含在 Locationmanipulator 类中),如下所示:
从这里我提供以下内容允许访问该字段的属性:
在 WP7.1 应用程序中(引用后通过“添加引用”对话框)我初始化 LocationManipulator 对象:
当我开始使用访问 ObservableCollection 字段时在 LocationManipulator 中,我收到以下错误:
此外,我可以在错误列表中看到以下消息:
我该如何解决此问题?我试图确保所有内容都是最新的(Silverlight、VS2010),并且我为每个对象类型使用了正确的引用。
非常感谢。
I've cobbled together a Windows Class Library (Called MPC_Core) using .NET 4, I'm referencing this class library within a Windows Phone 7.1 application.
I'm creating and initialising the ObservableCollection object (Contained within the Locationmanipulator class) like so:
From here I provide the following property which allows access to the field:
Within the WP7.1 application (After referencing it via the "Add References" dialog) I initialise the LocationManipulator object:
When I come to use access the ObservableCollection field within LocationManipulator, I receive the following error:
Additionally I can see the following messages within the error list:
How would I resolve this issue? I've tried to make sure everything is up to date (Silverlight, VS2010) and that I've used the correct references for each object type.
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该从 Silverlight 应用程序引用 Windows 库。您出现此错误的原因是该库引用了 .NET 4.0 的 ObservableCollection,而您的应用程序引用了 Silverlight。
如果你想使用这个库,你必须为 Silverlight 重新编译它。我认为没有一个简单的方法可以做到这一点。创建一个新的 Silverlight 库项目,添加文件,编译,并祈祷不必修改太多代码。
You're not supposed to reference a Windows library from a Silverlight app. You have this error because the library references the .NET 4.0's ObservableCollection, while your app references the Silverlight one.
If you want to use this library, you have to recompile it for Silverlight. I don't think there's an easy way to do this. Create a new Silverlight library project, add the files, compile, and pray for not having to modify too large portions of code.