【问题标题】:adding GLcontrol to visual studio toolbox将 GLcontrol 添加到 Visual Studio 工具箱
【发布时间】:2014-11-19 16:23:03
【问题描述】:

也许问题很简单,但我使用的是带有 WinForms 的 OpenTK,问题是我在工具箱中找不到 GLcontrol,所以我在 Form1.Designer.cs 中手动添加了它,这是代码 #region Windows 窗体设计器生成的代码

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        glcontrol1 = new OpenTK.GLControl();
        this.SuspendLayout();
        // 
        // glControl1
        // 

        // 
        // Form1
        // 
        this.Controls.Add(glcontrol1);
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(584, 561);     
        this.Name = "Form1";
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.ResumeLayout(false);

    }

    #endregion
    OpenTK.GLControl glcontrol1;

问题是当我在设计模式下打开 Form1 时,它会显示这些消息 “无法从程序集中加载类型 OpenTK.ToolkitOptions ...” “变量 glcontrol1 未声明或未分配” 我想要一种将 GLcontrol 添加到工具箱的方法,有人知道怎么做吗?

【问题讨论】:

  • 这是调用堆栈以备不时之需:OpenTK.GLControl..ctor(GraphicsMode mode, Int32 major, Int32 minor, GraphicsContextFlags flags) at OpenTK.GLControl..ctor()

标签: c# winforms opentk


【解决方案1】:

仔细检查您的项目引用,您需要OpenTK.dll 和OpenTK.GLControl.dll。

文档中的"Building a Windows.Forms + GLControl based application" 介绍了将 GLControl 添加到 WinForms 工具箱。

首先,创建一个您将放置 GLControl 的表单。右键单击工具箱的一些空白区域,选择“选择项目...”并浏览OpenTK.GLControl.dll。确保您可以在“.NET Framework Components”中找到列出的“GLControl”,如下图所示。

然后您可以将 GLControl 作为任何 .NET 控件添加到您的表单中。一个名为 glControl1 的 GLControl 将被添加到您的表单中。

【讨论】:

  • 谢谢,现在我有另一个问题,当我将 GLcontrol 拖到窗体时,出现相同的消息:无法从 OpenTK.GLControl..ctor 的程序集中加载类型 OpenTK.ToolkitOptions(GraphicsMode 模式, Int32 主要,Int32 次要,GraphicsContextFlags 标志)在 OpenTK.GLControl..ctor()
  • 有人告诉我可能是我的 OpenTK 中的问题,所以我安装了它,但出现了同样的问题! ,奇怪的是我在另一台计算机上打开了我的项目并且它工作了,也许是我的 Windows,虽然它曾经工作过,但我认为我有 Windows 8.1 x64 和另一台计算机的 Windows 7 x86。
  • 您可能拥有多个版本的 OpenTK,而 Visual Studio 会感到困惑。导航到 OpenTK/Binaries/OpenTK/Release 并运行 Examples.exe。这些例子有用吗?如果他们这样做了,(a) 将 OpenTK.dll 和 OpenTK.GLControl.dll 直接复制粘贴到您的项目中,(b) 从您的项目中删除现有的 OpenTK 引用,并且 (c) 添加您刚刚复制的 dll 作为项目引用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-03-27
  • 1970-01-01
  • 1970-01-01
  • 2011-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多