|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我用VS2008 C# NET2.0 NX7.5 写的代码生成EXE文件只能在UG->NXOPEN.执行一次.
执行第二次就报错: 内部错误内部访问违规!
难道是没有释放资源..可是我执行了Dispose() 也不行
代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NXOpen;
using NXOpen.UF;
namespace CreateNCgroupName
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Session theSession = Session.GetSession();
UI theUI = UI.GetUI();//必引用NXOpenUI
Part thePart = theSession.Parts.Work;
NXOpen.CAM.CAMSetup tSetup = thePart.CAMSetup;
NXOpen.NXMessageBox msg = theUI.NXMessageBox;
try
{
NXOpen.CAM.NCGroup ncGroup1;
ncGroup1 = tSetup.CAMGroupCollection.CreateProgram((NXOpen.CAM.NCGroup)theUI.SelectionManager.GetSelectedObject(0), "mill_contour", "PROGRAM", NXOpen.CAM.NCGroupCollection.UseDefaultName.False, "M1D1");
}
catch (NXException ex)//引用 NXOPEN.Utilities
{
theUI.NXMessageBox.Show("error!", NXMessageBox.DialogType.Error, ex.Message);
}
Dispose();
}
private void button2_Click(object sender, EventArgs e)
{
Dispose();
}
}
} |
|