zhonghua
路人甲
路人甲
  • 注册日期2005-04-01
  • 发帖数94
  • QQ
  • 铜币466枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1911回复:5

[求助]关闭程序时出现内存错误?

楼主#
更多 发布于:2006-10-25 19:12
<P>我用c#+AE开发了一个程序,加载一个shapefile文件,当关闭程序时,会出现一个内存错误;我如果只加载其他影像数据,不加载shapefile 文件,关闭程序时,不会出现上述错误。</P>
<P>请教大虾这是什么原因,如何解决?</P>
喜欢0 评分0
xxhhoddity
路人甲
路人甲
  • 注册日期2003-08-24
  • 发帖数409
  • QQ
  • 铜币1295枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-10-25 23:49
<P>初始化License了吗 </P>
GIS GSI IGS ISG SIG SGI
举报 回复(0) 喜欢(0)     评分
zhonghua
路人甲
路人甲
  • 注册日期2005-04-01
  • 发帖数94
  • QQ
  • 铜币466枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-10-26 09:19
我不清楚,请教大虾怎样初始化License?
举报 回复(0) 喜欢(0)     评分
xxhhoddity
路人甲
路人甲
  • 注册日期2003-08-24
  • 发帖数409
  • QQ
  • 铜币1295枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-10-26 11:33
<P>        private IAoInitialize m_AoInitialize = new AoInitializeClass();       </P>
<P>        private bool CheckLicenses()<br>        {<br>            //Create a new AoInitialize object<br>            if (m_AoInitialize == null)<br>            {<br>                System.Windows.Forms.MessageBox.Show("Unable to initialize. This application cannot run!");<br>                return false;<br>            }<br>            //Determine if the product is available<br>            esriLicenseStatus licenseStatus = (esriLicenseStatus)m_AoInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine);<br>            if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)<br>            {<br>                licenseStatus = (esriLicenseStatus)m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);<br>                if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut)<br>                {<br>                    System.Windows.Forms.MessageBox.Show("The initialization failed. This application cannot run!");<br>                    return false;<br>                }<br>            }<br>            else<br>            {<br>                System.Windows.Forms.MessageBox.Show("The ArcGIS Engine product is unavailable. This application cannot run!");<br>                return false;<br>            }<br>            return true;<br>        }</P>
<P>        private void ReleaseLicenses()<br>        {<br>            //Release COM objects and shutdown<br>            ESRI.ArcGIS.Utility.COMSupport.AOUninitialize.Shutdown();<br>            m_AoInitialize.Shutdown();<br>        }</P>
<P>        private void FormMain_Load(object sender, EventArgs e)<br>        {<br>            if (CheckLicenses() == false) this.Close();             <br>        }</P>
<P>        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)<br>        {<br>            ReleaseLicenses(); <br>        }</P>
[此贴子已经被作者于2006-10-26 11:34:10编辑过]
GIS GSI IGS ISG SIG SGI
举报 回复(0) 喜欢(0)     评分
xxhhoddity
路人甲
路人甲
  • 注册日期2003-08-24
  • 发帖数409
  • QQ
  • 铜币1295枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-10-26 11:36
这些拷贝到主窗代码中,那个FormMain换成你自己的窗体名称
GIS GSI IGS ISG SIG SGI
举报 回复(0) 喜欢(0)     评分
zhonghua
路人甲
路人甲
  • 注册日期2005-04-01
  • 发帖数94
  • QQ
  • 铜币466枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2006-10-26 12:02
<P>试了,这样做问题就消除了,多谢大虾了。但是不明白为什么要这样做?</P>
<P>大虾能稍微解释一下吗?</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部