The MonoMac library does not know that you need the CoreWLAN dynamic library to be loaded so it is not.  MM has code for loading the standard dynamic libraries.  In order for the bindings for CoreWLAN to work this library must be loaded prior to MM&#39;s initialization. <div>
<br></div><div>Duane<br><br><div class="gmail_quote">On Tue, Jan 18, 2011 at 3:15 PM, Ashok Gelal <span dir="ltr">&lt;<a href="mailto:ashokgelal@gmail.com">ashokgelal@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse"><div class="im">Awesome! That&#39;s seems to work. But can you please explain why I need to call the following:<div>

<span style="white-space:pre-wrap"><br></span></div></div><div><div class="im"><div style="color:rgb(102, 102, 102)"><span style="white-space:pre-wrap"><span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:arial;font-size:small">                dlopen(&quot;/System/Library/Frameworks/CoreWLAN.framework/CoreWLAN&quot;, 0);
</span></span></div><div><span style="white-space:pre-wrap"><span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:arial;font-size:small"><br></span></span></div>

</div><div class="im"><div class="gmail_quote">Thanks again. When I get some free time, I will rewrite the CoreWlan sample and will ask someone on git to pull it.</div><div class="gmail_quote"><br></div><div class="gmail_quote">
ashok</div><font color="#888888"><div class="gmail_quote">

<br></div></font></div></div></span><div class="gmail_quote"><div class="im">On Mon, Jan 17, 2011 at 8:28 AM, Duane Wandless <span dir="ltr">&lt;<a href="mailto:duane@wandless.net" target="_blank">duane@wandless.net</a>&gt;</span> wrote:<br>
</div><div><div></div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Try something like this:<div><br><div><span style="white-space:pre-wrap">        [System.Runtime.InteropServices.DllImport (&quot;/usr/lib/libSystem.dylib&quot;)]</span></div><div><div><span style="white-space:pre-wrap">        public static extern IntPtr dlopen (string path, int mode);
        [System.Runtime.InteropServices.DllImport(&quot;/usr/lib/libSystem.dylib&quot;)]
        public static extern string dlerror();

        static void Main (string[] args)
        {
                dlopen(&quot;/System/Library/Frameworks/CoreWLAN.framework/CoreWLAN&quot;, 0);
                Console.WriteLine(&quot;load error = {0}&quot;, dlerror());

                NSApplication.Init ();</span></div><div><span style="white-space:pre-wrap"></span><span style="border-collapse:collapse;color:rgb(102, 102, 102);font-family:helvetica, arial, freesans, clean, sans-serif;font-size:13px;line-height:19px">                var interfaces = CWInterface.SupportedInterfaces();</span></div>



<div><div><span style="white-space:pre-wrap">                </span>NSApplication.Main (args);</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div></div><div>Duane</div><div><br>
</div><div><br></div><br><div class="gmail_quote"><div><div></div><div>On Sun, Jan 16, 2011 at 11:26 PM, Ashok Gelal <span dir="ltr">&lt;<a href="mailto:ashokgelal@gmail.com" target="_blank">ashokgelal@gmail.com</a>&gt;</span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>
Hello All,<div>Right now I&#39;m working on rewriting a popular open source software inSSIDEr from MetaGeek <span style="font-family:helvetica, arial, freesans, clean, sans-serif;font-size:13px;line-height:20px"><a href="http://goo.gl/ompgJ" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;color:rgb(65, 131, 196);text-decoration:none;outline-style:none;outline-width:initial;outline-color:initial" target="_blank">http://goo.gl/ompgJ</a> makeing it cross platform using Mono and Gtk#. I&#39;ve managed to make the newly written application run in Windows and Linux, and just a few days ago we released an alpha version of it (<a href="https://github.com/metageek-llc/inSSIDer-2-Cross-Platform" target="_blank">https://github.com/metageek-llc/inSSIDer-2-Cross-Platform</a> - just the binaries for now) and so far the responses have been awesome! I&#39;ve met a guy or two talking against it for using Mono but, to be honest, I give a sh** about them.</span></div>





<div><span style="font-family:helvetica, arial, freesans, clean, sans-serif;font-size:13px;line-height:20px"><br></span></div><div><span style="font-family:helvetica, arial, freesans, clean, sans-serif;font-size:13px;line-height:20px">Now to the main point - to support the application so that it runs on Mac, I need CoreWlan framework. I&#39;ve successfully ran the program (without any Network Scan support) on Mac and it looks super awesome! I wrote the CoreWlan binding which is about 90% complete (see the attached corewlan.cs file), and it compiled fine without any error. I&#39;m pretty much sure only 90% coverage should allow me to at least write a simple &#39;hello, corewlan&#39; program but I&#39;m running out of luck. As soon as I call </span><span style="font-family:helvetica, arial, freesans, clean, sans-serif;font-size:13px;line-height:19px"><i>NSApplication.Init ()</i> and call my static method (<i>CWInterface.SupportedInterfaces()</i>, I get a segfault error right away. If I call the static method without calling <i>NSApplication.Init()</i>, I don&#39;t get any segfault but I always get a null value instead of an array of string.</span></div>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.5em !important;font-family:helvetica, arial, freesans, clean, sans-serif;font-size:13px">





I&#39;ve noticed that when trying to invoke the static method (or any other methods/ properties), the value of class_ptr is always 0x0.</p><p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.5em !important;font-family:helvetica, arial, freesans, clean, sans-serif;font-size:13px">





Here is the simple example that I&#39;m using:</p><p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">





</p><p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i>using System;</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><i><font color="#666666"><font face="helvetica, arial, freesans, clean, sans-serif"><span style="line-height:19px"></span></font><span style="font-family:helvetica, arial, freesans, clean, sans-serif;line-height:19px">using MonoMac.CoreWlan;</span></font></i></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i>namespace MacInssider</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i>{</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i><span style="white-space:pre-wrap">        </span>class MainClass</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i><span style="white-space:pre-wrap">        </span>{</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><i><font color="#666666"><font face="helvetica, arial, freesans, clean, sans-serif"><span style="line-height:19px"></span></font><font face="helvetica, arial, freesans, clean, sans-serif"><span style="line-height:19px"><span style="white-space:pre-wrap">                </span></span></font><span style="font-family:helvetica, arial, freesans, clean, sans-serif;line-height:19px">static void Main ()</span></font></i></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i><span style="white-space:pre-wrap">        </span>       {</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i>                    // NSApplication.Init(); // if I uncomment this out, I get a segfault error right away</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i><span style="white-space:pre-wrap">                </span>      var interfaces = CWInterface.SupportedInterfaces();</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i>                     // interfaces is always null at this point.</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><span style="font-family:helvetica, arial, freesans, clean, sans-serif;line-height:19px"><i><font color="#666666"><span style="white-space:pre-wrap"></span>               }</font></i></span></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i><span style="white-space:pre-wrap">        </span>}</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif" color="#666666"><span style="line-height:19px"><i>}</i></span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif"><span style="line-height:19px">My ultimate target is to get this example working using Mono </span></font><span style="font-family:helvetica, arial, freesans, clean, sans-serif;font-size:13px;line-height:20px">(<a href="http://goo.gl/YzEQy" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;color:rgb(65, 131, 196);text-decoration:underline;outline-style:none;outline-width:initial;outline-color:initial" target="_blank">http://goo.gl/YzEQy</a>). Can anyone help me where I&#39;m doing wrong? Or can help me port CoreWlan framework?</span></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><span style="font-family:helvetica, arial, freesans, clean, sans-serif;font-size:13px;line-height:20px">I&#39;ve attached the corewlan.cs file and also all the generated .g.cs files (I don&#39;t think attaching these .g files are required but just-in-case)</span></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif"><span style="line-height:20px">Thanks,</span></font></p>





<p style="margin-top:1em !important;margin-right:0px !important;margin-bottom:1em !important;margin-left:0px !important;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><font face="helvetica, arial, freesans, clean, sans-serif"><span style="line-height:20px">Ashok Gelal</span></font></p>





<p></p>
<br></div></div>_______________________________________________<br>
Mono-osx mailing list<br>
<a href="mailto:Mono-osx@lists.ximian.com" target="_blank">Mono-osx@lists.ximian.com</a><br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-osx</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div></div></div><br>
</blockquote></div><br></div>