A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
        We are using a CY7C68013A USB controller in a couple of our product. The PC software currently is using a third party driver solution and we would like to convert to using the Cypress Suite USB 3.4.1 libraries. The application currently is written in C++ so the first go at it I was trying to use the CYAPI.lib. It compiles fine, but if there is a (Cypress) device (with our VID,PID) connected to the USB port, the statement:   
USBDevice = new CCyUSBDevice(NULL);   
throws an exception. If no device is connected, it does not throw the exception.   
   
I then decided to try a C# solution, and started with the Control Center example. Again, if a device is connected the following statement:   
usbDevices = new USBDeviceList(DeviceMask);   
will generate 8-10 messages in the output window:   
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll   
If no device is connected, no exceptions.   
   
I am not sure where to look next, any suggestions.   
   
Thanks,   
Bjarne   
0 Likes
8 Replies
Anonymous
Not applicable
        you are supplying NULL instead of supplying the handle name... I believe that is the reason behind the error here... Can you upload your entire code here...   
0 Likes
Anonymous
Not applicable

Thank you for the reply aasi.
For some reason I don't get the exception in the C++ statement anymore, and I am not sure what I changed The help file says that supplying NULL for the handle is OK, if you don't want PnP notification, and it seems to work with NULL or a handle now. (The code is presently hacks into my old code, so it would not make much sense to post it).

Moving on, I am now trying to figure out how to implement the PnP callbacks, it sure would be nice if there was a C++ example somewhere.

Do you know why I might get the exceptions in the (unmodified) Control Center C# example? I do eventually want to move to managed code.

0 Likes
Anonymous
Not applicable
        If you have installed suiteusb3.4 You can find C++ examples in C:\Program Files\Cypress\Cypress Suite USB 3.4.1\CyAPI\examples... I think screamer example should be implementing PnP callbacks...   
I'm not sure why unmodified control center code is not compiling... i remember being able to compile it properly... What error are you seeing when you try to compile it...   
0 Likes
Anonymous
Not applicable
        Thank you, I was only looking in the examples directory at the top level, I should have dug further down.   
   
On the C# Control Center 'problem', it is a runtime exception, not a compile error, I get when executing the following statement in debug mode:   
usbDevices = new USBDeviceList(DeviceMask);   
will generate 8-10 messages in the output window:   
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll   
If no device is connected, no exceptions.   
0 Likes
Anonymous
Not applicable
        Dude, I tried replicating the issue at my end... it works fine for me... does your device belong to a specific class or is it generic usb... What is the length of your descriptor table...   
0 Likes
Anonymous
Not applicable
        Interesting, did you run the application in debug mode, and you did not see this message in the Visual Studio output window?   
   
The application works, but I am always concerned when I see exceptions being thrown, and I was asking why this might be.   
0 Likes
Anonymous
Not applicable
        I didn't see these exceptions... i was running bulkloop example on my board connected to cyusb.sys and i didn't see these errors... since you are talking about using a third party driver earlier i was thinking it might have something to do with the descriptor of the device because if there is discrepancy in the descriptor the console is bound to throw exceptions....   
0 Likes
Anonymous
Not applicable
        OK, thanks.   
0 Likes