先贴程序
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BMW = Bentley.MicroStation.WinForms;
using BWW = Bentley.Windowing.WindowManager;
using BMI = Bentley.MicroStation.InteropServices;
using BCOM = Bentley.Interop.MicroStationDGN;
using BM = Bentley.MicroStation;namespace MSApp
{
public partial class Form1 : Form
{
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); }
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Button button1 = (Button)sender;
button1.Enabled = false;
BCOM.DesignFile myDGN = MSApp.ComApp.OpenDesignFile(@"D:\wei\平仙南.dgn", false, BCOM.MsdV7Action.UpgradeToV8);
Console.WriteLine(myDGN.Name); Console.WriteLine(“!!!!”); button1.Enabled = true;
}
}
}
在黄色的地方报错,这个程序就是一个简单的窗体,有一个按钮,点击按钮执行下面几条语句,
未处理FileNotFoundException
在 System.IO.FileNotFoundException 中第一次偶然出现的“System.Windows.Forms.dll”类型的异常
这个dll存在于windows文件下面的一个文件夹里面忘记路径了,但是不知道为什么它报这个错误,Form本身就是这个dll里面的要是没有这个dll,Form也不可能显示吧,所以感觉很奇怪,把红色两行注释掉以后,程序顺利进行,输出“!!!!”。
BCOM命名空间下面也有一个BCOM.Application难道这个和System.Windows.Forms.Application冲突吗?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BMW = Bentley.MicroStation.WinForms;
using BWW = Bentley.Windowing.WindowManager;
using BMI = Bentley.MicroStation.InteropServices;
using BCOM = Bentley.Interop.MicroStationDGN;
using BM = Bentley.MicroStation;namespace MSApp
{
public partial class Form1 : Form
{
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); }
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Button button1 = (Button)sender;
button1.Enabled = false;
BCOM.DesignFile myDGN = MSApp.ComApp.OpenDesignFile(@"D:\wei\平仙南.dgn", false, BCOM.MsdV7Action.UpgradeToV8);
Console.WriteLine(myDGN.Name); Console.WriteLine(“!!!!”); button1.Enabled = true;
}
}
}
在黄色的地方报错,这个程序就是一个简单的窗体,有一个按钮,点击按钮执行下面几条语句,
未处理FileNotFoundException
在 System.IO.FileNotFoundException 中第一次偶然出现的“System.Windows.Forms.dll”类型的异常
这个dll存在于windows文件下面的一个文件夹里面忘记路径了,但是不知道为什么它报这个错误,Form本身就是这个dll里面的要是没有这个dll,Form也不可能显示吧,所以感觉很奇怪,把红色两行注释掉以后,程序顺利进行,输出“!!!!”。
BCOM命名空间下面也有一个BCOM.Application难道这个和System.Windows.Forms.Application冲突吗?
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
这三句话就算加了
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
System.Windows.Forms.Application.Run(new Form1());
也还是老错误啊
public partial class Form1 : Form
{
static void Main()
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
从异常信息看,应该是这行的问题。
LZ可以确认一下D:\wei\平仙南.dgn,是否有这个文件,如果有你可以把文件名改成英文的再试试。检查一下中英文字符。