平常用 python。因为需要调用第三方控件的方法,摸索着使用 c#,网上关于 ocx 控件的教程很少,举步维艰。希望各位大佬能指点下问题。 C#小白,轻喷谢谢!!!
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AxXX;
namespace WindowsFormsControlLibrary2
{
    public partial class UserControl1: UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }
        private void UserControl1_Load(object sender, EventArgs e)
        {
            AxXX xx = new AxXX();
            ((System.ComponentModel.ISupportInitialize)(xx)).BeginInit();
            this.Controls.Add(xx);
            ((System.ComponentModel.ISupportInitialize)(xx)).EndInit();
            xx.AddImage("168", "123", 1, 90);            
        }
    }
}
异常:
System.BadImageFormatException
  HResult=0x8007000B
  Message=未能加载文件或程序集“file:///C:\Users\aaronhua\Desktop\dllproject\WindowsFormsControlLibrary2\WindowsFormsControlLibrary2\obj\x86\Debug\WindowsFormsControlLibrary2.dll”或它的某一个依赖项。试图加载格式不正确的程序。
  Source=mscorlib
  StackTrace:
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.