<div>Hi,</div>
<div> </div>
<div> I am using the Ipopt lib(Release version) from C#. So, I have a dll wrapper for the ipopt.lib. So, after I run the Initialize method I get an exception saying ""Attempted to read or write protected memory. This is often an indication that other memory is corrupt." </div>
<div> </div>
<div> Giving a C++ snippet of my code below:</div>
<div> </div>
<div> <font color="#0000ff" size="2"></font></div>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<p>class<font size="2"> Wrapper</font></p>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<div>{</div>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<div><font color="#0000ff" size="2">private</font><font size="2">:</font></div>
<div>SmartPtr<IpoptApplication> Impl;</div>
<div>SmartPtr<TNLP> mynlp; </div>
<div> </div>
<div>public:</div>
<div><font color="#0000ff" size="2"><font size="2">
<p>ApplicationReturnStatus </p></font></font><font size="2">Initialize()<br>{ </font><font size="2">
<p>return Impl->Initialize(</p></font><font size="2">);</font><font size="2">
<p>}</p></font></div></blockquote><font size="2">
<p>};</p><font color="#0000ff" size="2">
<p>class</p></font><font size="2"> IpOptNLP: </font><font color="#0000ff" size="2">public</font><font size="2"> TNLP
<p>{ </p>
<p></p></font><font color="#0000ff" size="2">private</font><font size="2">:
<p>Wrapper* m_pcUnManagedWrapper;</p>
<p></p>
<p></p></font><font color="#0000ff" size="2">public</font><font size="2">:
<p>IpOptNLP();</p>
<p></p></font><font color="#0000ff" size="2">virtual</font><font size="2"> ~IpOptNLP();
<p>IpOptNLP(Wrapper* pcWrapper) { <font size="2">m_pcUnManagedWrapper = pcWrapper;}</font></p><font color="#0000ff" size="2">
<p>virtual</p></font><font size="2"> </font><font color="#0000ff" size="2">bool</font><font size="2"> get_nlp_info(</font><font color="#0000ff" size="2">int</font><font size="2">& n, </font><font color="#0000ff" size="2">int</font><font size="2">& m, </font><font color="#0000ff" size="2">int</font><font size="2">& nnz_jac_g, </font><font color="#0000ff" size="2">int</font><font size="2">& nnz_h_lag, IndexStyleEnum& index_style); //And so on</font>
<p><font size="2">}</font></p>
<p> </p>
<p>Now when I invoke the Initialize function from C#(after exporting the dll) I get an exception when <em>Impl->Initialize(</em><font size="2"><em>)</em> is getting invoked. And while debugging I see the reference count for both Impl and mynlp are zero. </font></p>
<p>Can someone please point out where I might be going wrong?</p>
<p>Thanks,</p>
<p>Nandini</p>
<p> </p>
<p><font size="2"> </font></p></font></font></blockquote></blockquote>
<div> </div>
<div> </div>