Monodevelop 警告“无法为类型为 xxxx 的小部件生成代码”
大约 2 年前,我在 Fedora 下使用 MonoDevelop V1 和后来的 V2(测试版,从源代码编译,这是一个多么伟大的使命)从事一个 C# 项目。该项目失败了。现在我正在让它起死回生,但我已经将我的开发平台更改为Debian(测试,即squeeze),其中有MonoDevelop V2.2。
我对 V2.2 的功能非常满意,但我有一个讨厌的小问题。所有代码都编译正常,但在编译运行结束时,我留下了许多警告,如主题行中所示。显然,当我尝试运行该应用程序时,当我打开任何使用这些小部件的内容时,我会在左侧、右侧和中心出现异常。
有趣的是,包含小部件的库编译得很好。但不知何故,这些小部件(不是全部,只有一两个)不会在界面上公开,然后使用它们的后续对话框或窗口会抛出上述警告。
有人遇到过这个问题吗?我用谷歌搜索了这个,出现的只是迈克尔·哈钦森(Michael Hutchinson)举起双手说“抱歉,帮不上忙”。我确实需要解决这个问题,否则我将不得不从头开始重写大量代码。
About 2 years ago I worked on a C# project, using MonoDevelop V1 and later V2 (beta release, compiled from source, what a mission) under Fedora. The project went dead. Now I am bringing it back to life, but I have changed my development platform to Debian (testing, i.e. squeeze), which has MonoDevelop V2.2.
I am mostly very pleased with the features of V2.2, but I have a nasty little problem. All the code compiles OK, but at the end of the compilation run I am left with lots of warnings as in the subject line. Obviously, as soon as I try and run the application, I get exceptions left, right and center when I open anything that uses these widgets.
The funny thing is that the library containing the widgets compiles just fine. But somehow these widgets (it's not all of them, only one or two) don't get exposed on the interface, and then subsequent dialogs or windows using them throw the above warning.
Has anybody had this problem? I have googled this and all that comes up is Michael Hutchinson throwing his hands in the air and saying "sorry, can't help here". I really need a fix for this, otherwise I will have to rewrite substantial chunks of code from scratch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议尝试 MonoDevelop 2.4,但无论如何这里有一些提示。
如果您有一个程序集使用在同一程序集中实现的自定义小部件,那么您可能会遇到先有鸡还是先有蛋的问题,因为 MonoDevelop 需要构建的程序集才能找到自定义小部件,但这就是您要构建的程序集。在收到报告的警告后重新构建项目可以轻松解决此问题。请注意,您必须构建,而不是重建,因为重建将删除程序集,并且您将再次遇到相同的问题。
如果您没有遇到上述问题,或者解决方案不起作用,则问题可能是包含导出小部件信息的objects.xml 文件未正确更新。您将在实现自定义小部件的项目中的隐藏 gtk-gui 文件夹中找到该文件。打开文件并检查是否在其中声明了所有自定义小部件。如果缺少小部件,请尝试打开小部件的源代码文件并进行一些小的更改(例如空格更改),然后再次构建项目。 MonoDevelop 应该正确更新该文件。
如果您仍然遇到问题,请提交错误报告。
I would recommend trying MonoDevelop 2.4, but in any case here are some hints.
If you have an assembly which uses custom widgets implemented in the same assembly, you may be having a chicken-egg problem, since MonoDevelop needs the built assembly in order to find the custom widgets, but that's the assembly you are trying to build. This problem can be easily solved by building again the project after you get the warnings you reported. Beware, you have to build, not rebuild, since rebuild will delete the assembly and you'll hit the same problem again.
If you are not having the above problem, or if the solution doesn't work, the problem may be that the objects.xml file that contains the information about the exported widgets is not properly updated. You'll find that file in the project that implements the custom widgets, in a hidden gtk-gui folder. Open the file and check if the all the custom widgets are declared there. If a widget is missing, try opening the source code file of the widget and do a small change (e.g. a whitespace change) and then build the project again. MonoDevelop should be properly updating the file.
If you are still having trouble, please file a bug report.
我想我找到了出路。不确定这是否是“官方”方法,但它似乎有效。
在此库中,普通小部件的类定义如下所示:
namespace Amino.Common
{
<代码>
如果我现在在类语句前面添加两个附加声明,如下所示:
命名空间 Amino.Common
{
<代码>
然后
也许有人可以对此提供一些额外的说明,我很想更好地理解这一点。
I think I found a way out. Not sure whether this is the "official" method, but it seems to work.
In this library a normal widget's class definition starts like this:
namespace Amino.Common
{
If I now add two additional declarations right in front of the class statement, like this:
namespace Amino.Common
{
then
Maybe somebody could shed some additional light on this, I would love to understand this better.