【问题标题】:Is there a way to use a custom control in the designer and avoid the GAC?有没有办法在设计器中使用自定义控件并避免 GAC?
【发布时间】:2010-02-15 12:53:52
【问题描述】:

我找到了一个很棒的图书馆here。它是在 Windows 窗体中完成的 AeroWizard,它可以优雅地处理 Aero Basic。令人敬畏的是它应该有设计师的支持。当我尝试在表单设计器中打开示例中的任何 WizardPages 时,我收到此错误:

Could not find type 'Aero.Controls.MainInstructionsLabel'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

我的项目中引用了该库Aero.ControlsAero.Wizard,所以我不太确定出了什么问题。

我是否需要 GAC 注册程序集才能获得设计人员支持?

编辑: 我刚刚检查了反射器,这是参考

Aero.Controls
mscorlib
系统
系统.绘图
System.Windows.Forms
user32.dll

Aero.Wizard
mscorlib
系统
系统.绘图
System.Windows.Forms
dwmapi.dll
gdi32.dll
user32.dll
uxtheme.dll

除了本机 Dll 之外,我没有什么关心的,但我看不出这些会如何阻止表单在设计器中呈现。

这是设计师的屏幕截图: alt text http://www.ceasetopanic.com/wp-content/uploads/2010/02/compile-error.jpg

【问题讨论】:

    标签: c# winforms


    【解决方案1】:

    只要使用它的项目引用了 DLL,Visual Studio 就可以轻松找到控件并加载它。您可能想尝试构建项目,然后关闭并重新打开 Visual Studio。程序集不需要在 GAC 中。

    您也可以尝试在 Reflector 中打开程序集,看看它是否引用了您没有的其他程序集。如果 Aero.Controls 引用了您尚未引用的另一个程序集,并且 Visual Studio 在探测它时找不到它,您将看到这种错误,并且 GAC 对上述程序集进行处理无法解决此问题。

    【讨论】:

    • 这听起来像是找不到另一个引用程序集的问题。
    • 原来程序集已签名,我的 lib 文件夹中缺少“snk”文件,我从源代码复制,现在设计器加载 jsut 正常。
    【解决方案2】:

    Visual Studio 需要能够找到它们。通常这意味着 GAC,但是您可以使用我使用的技巧 here on my blog 来欺骗应用程序以寻找其他地方。在编写插件时,我用它来欺骗 Outlook 以找到我们的 dll。我个人认为 GAC 在维护方面可能不那么令人头疼。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-10
      • 1970-01-01
      • 2019-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-06
      相关资源
      最近更新 更多