locked
A Form blocks after NetMonAPI.cs RRS feed

  • Question

  • Hallo,

    I am writing an Application in C# with NMAPI.dll and NetmonAPI.cs and I want to show the content of an telegram and telegram field details. The Details od DLL are from "NetMon Expert SDK"

    Due to unsafe code, I have two Projects in my solution: DLL with NMAPI.dll and NetmonAPI.cs  and main project as Windows Form Application with a Reference on DLL with NMAPI.dll.

    In main Project there is a Form (Form2) with few radioButtons and few textboxes and without referencing to NETMONAPI. At the beginning, I can show Form2 and work with it without any problem.

    But if I first call my DLL with NMAPI, and then show the Form2, the form blocks after few clicks and I have to reset the application. The telegram (frame) is in that case good parsed and is showed very well.

    I do not have problem only with this particular form. I have a general problem with any form after call of NMAPI.DLL.

    Obviosly there is a Memory Problem. Any Idea?

    I have tried with Network Monitor 3.3 and Network Monitor 3.4 Beta.

    Thanks in advance

     

    Thursday, April 29, 2010 8:39 AM

All replies

  • I think I might need to work with a specific simplified example in order to understand this problem.  Perhaps the best thing to do is create a bug on our Connect site and attache a simplified sample project that reproduces the issue.  That will make it easier for our team to determine what might be happening.

    I'm not aware of any problems like this, but it might be specific to how you are using the API.  In general I would just make sure you cleanup all handles by closing them and additionally calling NmCloseAPI before unloading the DLL. 

    Thanks,

    Paul

    Thursday, April 29, 2010 2:42 PM
  • Thanks for your Answer.

    All handles are closed, NmCloseAPI is called, but what do you mean with "unloading DLL"?

    Where exactly and how can I attach my sample project?

     

    Thursday, April 29, 2010 3:11 PM
  • I guess I can't tell if you are manualy loading the DLL, like with a LoadLibrary type call or if you are statically linking to it.  I suppose there might also be some other way with c# that I'm not familiar with.

    To open a bug, go to the Connect site and then to our Network Monitor 3 connection.  Then select the feedback item and create a feedback bug report.  After submiting, you should see the feedback on your dashboard.  From there you should be able to open it up and attach files.

    Paul

    Thursday, April 29, 2010 4:31 PM
  • If you are only using C#, you shouldn't have to use the NMAPI.dll.  All you need to do is reference the NetmonAPI.cs file to your C# project.  The CLR will attempt to find the NMAPI.dll on your system for you when it encounters a call into it (via the NetmonAPI.cs wrapper).  This is why you see the DllNotFoundException in the main() function of the SDK:

                // Load API             
                try
                {
                    initialized = Program.InitializeNMAPI();
                }
                catch (BadImageFormatException)
                {
                    Console.WriteLine("There was an error loading the NMAPI.\n\nPlease ensure you have the correct version installed for your platform.");
                }
                catch (DllNotFoundException)
                {
                    Console.WriteLine("There was an error loading the NMAPI DLL.\n\nPlease ensure you have Network Monitor 3.3 installed or try rebooting.");
                }

    I'm sure there's ways that you can load the NMAPI.dll file dynamically in C# and avoid the NetmonAPI.cs file, but it's better to just use the .cs file we provide as then it basically all gets done for you.

    If VS is complaining about the unsafe code, make sure you check the "Allow Unsafe Code" in your project settings.


    Michael Hawker | Program Manager | Network Monitor
    Friday, April 30, 2010 12:38 AM