无法在 VS 2008 Designer 中显示自定义控件 -- .NETCF
我在 Visual Studio 中的 .NETCF windows mobile 项目中显示自定义(继承)控件时遇到问题。 该控件在设计器表面上显示为一个灰色框,其中写有类名称。
作为一个测试用例,我有一个简单的控件定义为:
public class ucButton2 : Button
{
}
应该就像一个按钮,但它给出了有趣的行为。
过去,我使用设计时属性文件解决了这个问题或类似问题。 因此,我将文件 DTA.xmta 包含在以下内容中。
<?xml version="1.0" encoding="utf-16"?>
<Classes xmlns="http://schemas.microsoft.com/VisualStudio/2004/03/SmartDevices/XMTA.xsd">
<Class Name="MyProject.CustomControls.ucButton2">
<Description>Testbutton</Description>
<DesktopCompatible>true</DesktopCompatible>
</Class>
</Classes>
现在事情变得非常奇怪——我开始在不相关的类型化数据集文件中从 genasm.exe 收到编译错误。
遵循本文最后评论的建议: http://www.simonrhart.com/2008/ 02/upgrading-your-solutions-to-visual.html
我将 DTA.xmta 更改为具有“嵌入式资源”的构建操作
现在应用程序可以编译,但没有任何变化 - 设计器表面仍然只显示带有类名的空框。
我已关闭并重新打开 Visual Studio,以确保不会发生奇怪的缓存 - 相同的行为。
就像我说的,过去 xmta 文件已经解决了这种问题。 但这次没有。 但同时,在过去,添加 xmta 文件并不会导致 genasm.exe 在编译时出现 barf。 在我的另一个项目中,我的 xmta 文件的构建操作为“无”,而不是“嵌入资源”。
在运行时,一切正常。 这纯粹是一个设计时问题。 任何帮助将非常感激。
I'm having problems displaying custom (inherited) controls in my .NETCF windows mobile project in Visual Studio. The control appears on the designer surface as a gray box with the class name written in it.
As a test case I have a simple control defined as:
public class ucButton2 : Button
{
}
Should be just like a button but it gives the funny behavior.
In the past I've solved this problem or similar problems with a Design Time Attributes file. So I included the file DTA.xmta with the following contents
<?xml version="1.0" encoding="utf-16"?>
<Classes xmlns="http://schemas.microsoft.com/VisualStudio/2004/03/SmartDevices/XMTA.xsd">
<Class Name="MyProject.CustomControls.ucButton2">
<Description>Testbutton</Description>
<DesktopCompatible>true</DesktopCompatible>
</Class>
</Classes>
Now things get truly bizarre -- I start getting compile errors from genasm.exe in unrelated Typed Data Set files.
Following advice from the last comment on this post:
http://www.simonrhart.com/2008/02/upgrading-your-solutions-to-visual.html
I changed DTA.xmta to have a build action of "Embedded Resource"
Now the app compiles, but nothing has changed -- the designer surface still shows just an empty box with the class name.
I've closed and re-opened Visual Studio to ensure there's no weird caching happening -- same behavior.
Like I said, in the past the xmta file has solved this kind of problem. But it didn't this time. But at the same time, in the past, adding an xmta file didn't cause genasm.exe to barf at compile time. In my other project my xmta file has a build action of 'none', not 'embedded resource'.
At run time, everything works fine. This is purely a design time problem. Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想说您将 DesktopCompatible(true) 作为自定义属性添加到控件中。 请参阅:这篇文章
I'd say you add DesktopCompatible(true) as a Custom Attribute to the control. See: this post
这是因为智能设备控件设计器不支持视觉继承——或者我应该说它没有丰富地显示它。 无论是由于代码缺陷还是设计原因,它都不像桌面 .NET 控件设计器那样工作。 有时会显示,有时不显示。
但是您的自定义控制代码仍然可以工作,只是并不总是按预期显示。
This is because the smart device control designer does not support visual inheritance -- or should I say it doesn't display it richly. Whether by code defect or by design, it doesn't work like desktop .NET control designer. Sometimes it will display it, sometimes it won't.
But your custom control code will still work, it just doesn't always display as expected.