平常用 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)
1
ItFunly 2019-09-12 10:05:34 +08:00
选择 x86 或 x64 编译
|