LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"This class contains no public constructors" message

Hi,

I am trying to call a C# class library by using the .NET constructor. I browse for my .dll and when selecting my class, the constructor bow dispalys: This class contains no public constructors.

I tried everything, up to a point where I went back to the basics, yielding the same results. Here is my code:


using System;

public class TestInterface
{
    public TestInterface()
    {
    }

    public bool IsWorking()
    {
        return bReturn;
    }

    protected bool bReturn = false;
}


What am I doing wrong? I should at least be able to see the constructor, and then invoke IsWorking().

Thank you very much for you rhelp,

Fred
Message 1 of 43
(10,285 Views)

Hi Fred,

I have a few more questions for you. What version of LabVIEW are you using and which version of Visual Studios are you using? Also, do you think it would be possible for you to post your project files so that I can try to recreate the same error on my end? This would help me determine what could be the cause of the problem. Thanks!

National Instruments
Applications Engineer
0 Kudos
Message 2 of 43
(10,249 Views)
Hi CarlaU

Thanks for your help. LabVIEW version is 8.5 and Visual Studio is 2005.

The simple code I posted yesterday worked after I called my file the same name as my class.
My original task is to connect a Cypress USB uController device to my computer and then talk to it. I took the source code from our in-house software and trimmed it until the constructor 're-appeared' in the list This happens whenever I instantiate a CyUSB variable. They are commented in the code provided below.

So:
CyUSB variable commented = Constructor visible in LabVIEW
CyUSB variable uncommented= no Constructor


using System;
using System.Diagnostics;
using CyUSB;

    public class LV_NET_test
    {

        public LV_NET_test()
        {
        }


        public delegate void PnPCallback(bool bDeviceConnected);
        public event PnPCallback PnPCallbackEvent;

        //private CyUSB.App_PnP_Callback _evHandler = null;
        //private CyUSB.CyUSBDevice _Device = null;
        //private CyUSB.USBDeviceList _usbDevices = null;
        //private CyUSB.CyControlEndPoint _ctrlEndPt = null;

    }


My guess is that LabVIEW needs to know the location of CyUSB.dll. I tried the LabVIEW 8.5 root directory, but to no avail.

Thank you very much for your advice!
Fred
0 Kudos
Message 3 of 43
(10,234 Views)
You should take a look at this KnowledgeBase article:
"How LabVIEW Locates .NET Assemblies"
- http://digital.ni.com/public.nsf/allkb/C4EA5ABBEB67AF7C862573F3004D4421?OpenDocument

It explains where LabVIEW looks to find your .NET assembly.  Make sure your CyUSB.dll is in one of those places and then see if it works.
Kristen
National Instruments
0 Kudos
Message 4 of 43
(10,223 Views)
Thank you very much Kristen,

I got LabVIEW to recognize the CyUSB.dll by creating a project and copying the dll in the same directory. I can now start developping some cool stuff!

Thanks again!
Fred
0 Kudos
Message 5 of 43
(10,201 Views)
You are welcome.  Glad you got it working!
Kristen
National Instruments
0 Kudos
Message 6 of 43
(10,200 Views)

hello Eudaemonic :

   I have a same problem about dll. I  call a C# class library by using the .NET constructor. Have some function appear "This class contains no public constructors". I saw  you have to solve this problem, and hope you  help me. my dll is Cyusb.dll. 

  my email is : songyongji2010@163.com

thank you !

0 Kudos
Message 7 of 43
(9,403 Views)

Hello,

 

Have you already tried all the suggestions in the article:

How LabVIEW Locates .NET Assemblies?

 

National Instruments
0 Kudos
Message 8 of 43
(9,374 Views)

hello  

   thank you reply. but I dont understand this article.  you can explain :I use .net connect dll , How should I do.

0 Kudos
Message 9 of 43
(9,355 Views)
hello. I have a same problem above CyUSB.dll, "This class contains no public constructors" message" can you send you example to me . or tell me how to do. thank you!
0 Kudos
Message 10 of 43
(9,221 Views)