Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



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

Post Reply
Follow this topic



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

bchristensen posted on 20 Jul 2009 10:12 AM PST
Member
7 Forum Posts
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



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

aasi posted on 21 Jul 2009 01:17 AM PST
Cypress Employee
1090 Forum Posts
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...

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

bchristensen posted on 21 Jul 2009 09:57 AM PST
Member
7 Forum Posts

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.



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

aasi posted on 21 Jul 2009 08:37 PM PST
Cypress Employee
1090 Forum Posts
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...

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

bchristensen posted on 22 Jul 2009 09:01 AM PST
Member
7 Forum Posts
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.

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

aasi posted on 24 Jul 2009 12:04 AM PST
Cypress Employee
1090 Forum Posts
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...

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

bchristensen posted on 24 Jul 2009 03:43 PM PST
Member
7 Forum Posts
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.

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

aasi posted on 24 Jul 2009 08:43 PM PST
Cypress Employee
1090 Forum Posts
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....

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

bchristensen posted on 25 Jul 2009 08:46 AM PST
Member
7 Forum Posts
OK, thanks.




ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20