阅读:2094回复:5
[求助]关闭程序时出现内存错误?
<P>我用c#+AE开发了一个程序,加载一个shapefile文件,当关闭程序时,会出现一个内存错误;我如果只加载其他影像数据,不加载shapefile 文件,关闭程序时,不会出现上述错误。</P>
<P>请教大虾这是什么原因,如何解决?</P> |
|
1楼#
发布于:2006-10-25 23:49
<P>初始化License了吗 </P>
|
|
|
2楼#
发布于:2006-10-26 09:19
我不清楚,请教大虾怎样初始化License?
|
|
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编辑过]
|
|
|
4楼#
发布于:2006-10-26 11:36
这些拷贝到主窗代码中,那个FormMain换成你自己的窗体名称
|
|
|
5楼#
发布于:2006-10-26 12:02
<P>试了,这样做问题就消除了,多谢大虾了。但是不明白为什么要这样做?</P>
<P>大虾能稍微解释一下吗?</P> |
|