Libnodave.dll v8.4.5 in C#.Net

amir mans
2010-04-04
2013-05-09
  • amir mans

    amir mans - 2010-04-04

    I have some problem with Libnodave.dll in c#.net,when i run my project,show me "Unable to load Libnodave.dll" and show me : "Exception from HRESULT: 0x8007007E".can you help me?
    this my code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;

    namespace WindowsApplication3
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();

            }

            static libnodave.daveOSserialType fds;
            static libnodave.daveInterface di;
            static libnodave.daveConnection dc;
            //static int rack = 0;
            //static int slot = 2;

            private void button1_Click(object sender, EventArgs e)
            {
                try
                {

                    int a = 0, res, b = 0, c = 0;
                    float d = 0;

                    fds.rfd = libnodave.openSocket(102, txt_ip.Text);
                    fds.wfd = fds.rfd;
                    if (fds.rfd > 0)
                    {
                        di = new libnodave.daveInterface(fds, "IF1", 0, libnodave.daveProtoISOTCP, libnodave.daveSpeed187k);
                        di.setTimeout(1000000);
                        //     res=di.initAdapter(); // does nothing in ISO_TCP. But call it to keep your programs indpendent of protocols
                        //     if(res==0) {
                        dc = new libnodave.daveConnection(di, 0, com_rack.SelectedIndex, com_slot.SelectedIndex);
                        if (0 == dc.connectPLC())
                        {
                            res = dc.readBytes(libnodave.daveFlags, 0, 0, 16, null);
                            if (res == 0)
                            {
                                a = dc.getS32();
                                b = dc.getS32();
                                c = dc.getS32();
                                d = dc.getFloat();
                                MessageBox.Show("FD0: " + a);
                                MessageBox.Show("FD4: " + b);
                                MessageBox.Show("FD8: " + c);
                                MessageBox.Show("FD12: " + d);
                            }
                            else
                                MessageBox.Show("error " + res + " " + libnodave.daveStrerror(res));
                        }
                        dc.disconnectPLC();
                        //     }    
                        //     di.disconnectAdapter(); // does nothing in ISO_TCP. But call it to keep your programs indpendent of protocols
                        libnodave.closeSocket(fds.rfd);
                    }
                    else
                    {
                        MessageBox.Show("Couldn't open TCP connaction to " + txt_ip.Text);
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
               
            }

            private void button2_Click(object sender, EventArgs e)
            {
               
                libnodave.openSocket(120, "176.19.22.1");
            }

        }
    }

     
  • jon

    jon - 2011-03-20

    Have you copied the libnodave.dll (not the .net you should have as reference in the project) in the project Debug/Release area or in Windows/System32?

     
  • Michele Ciampichetti

    I've the same error, but I've both of dll into .\bin\Debug folder.

    I'm using win 7 32bit.

    I have a correct reference to .net dll.

    Any ideas?

    Thanks for your time

    Michele

     
  • Arnaud

    Arnaud - 2012-12-07

    Thanks sloggi, it's works ! with C# 2010 Express

     

Log in to post a comment.