LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

AWS DynamoDB w/.NET SDK Help

Hi all,

 

I have been playing around with the DynamoDB SDK for .NET.  It's not ideal for labview, as it's littered with typed object references that need to be built rather than just passing strings or even JSON.

 

However, I have run into one bit that I cannot figure out.  I have noticed that I get a "Key cannot be NULL" error if I use an object constant instead of the constructor.  So far I have been able to find and place constructors for all the objects... except one:

System.Collections.Generic.Dictionary

 

I can't seem to create that constructor.  I can find System.Collections and other children from that, but not even System.Collections.Generic.

 

I have never run into this before; any ideas how to deal with it?

 

DynamoDB.png

 

 

0 Kudos
Message 1 of 9
(4,103 Views)

Creating a .NET generic object in LabVIEW is not possible with a constructor.  I've had some success creating them using the .NET type library.  Try this:

 

Create NET generic.png

1st node is in the System.Type class in mscorlib.  The second one is System.Activator in mscorlib.  The third one is a generic "To more specific class" node from the LabVIEW class palette.  

 

According to the .NET docs, System.Activator.CreateInstance "Creates an instance of the specified type using that type's parameterless constructor", so as long as the Dictionary can be created with parameterless constructor, it should work if you get the exact typeName match correct.

Message 2 of 9
(4,067 Views)

I just found that and was playing with it- so thank you.

 

But I am still getting an error with it, when it tries to create the AWS object...

 

Using the typeName:

System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[Amazon.DynamoDBv2.Model.AttributeValue, AWSSDK.DynamoDBv2, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604]]

 

The System.Type() call runs without error- but creates a NULL reference, so the Activator Errs out:

 

Invoke Node System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: type <append><b>System.ArgumentNullException</b> in dynamodb.vi

 

Note:  If I replace the AWS descriptor with the System String, I don't get a null reference out of System.Type.getType().  Also, I have messed up the AWS name on purpose, and I get an error saying the path to the assembly is incorrect, so I think the problem is that I need to seed the constructor with something.

 

 

 

0 Kudos
Message 3 of 9
(4,058 Views)

There's another format of the Activator.CreateInstance function that takes as its input an array of "Object" references and then uses that.  You could try passing in objects that resemble one of the other constructors for dictionaries as seen on this page?  Long shot, but maybe?

Message 4 of 9
(4,052 Views)

I'll give that a shot.  Note:  I can't even create the object from this description alone without the null error:

 

Amazon.DynamoDBv2.Model.AttributeValue, AWSSDK.DynamoDBv2, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604

0 Kudos
Message 5 of 9
(4,049 Views)

Thanks for the help, but it's not working.  Not sure how to go about this unless I can figure out how to generate the object from within the AWS assembly and then clear it and populate it.

0 Kudos
Message 6 of 9
(4,046 Views)

Hi Jed,  I just came across your post while trying to solve a different problem.  I used the aws sdk version 1 years ago and it still works.  But now I'm trying to update for new features and I can't figure out how to get the .net version 2 or 3 aws sdk.  I see in your diagram that you're using version 2.  I also see all this instruction related to nuget, but I couldn't make that work.  Do you have any pointers?

Thanks,
Pat

0 Kudos
Message 7 of 9
(3,811 Views)

Sadly, I never got it working.  😞

0 Kudos
Message 8 of 9
(3,799 Views)

Hi, Thanks for your reply.  I have most of this dynamo db working on my end, so if you have some questions you can try me.  My problem is that I'm using version 1 of AWS SDK, and they're up to version 3 now.  And I could not see how to install the new dll.  So I settled for doing scans with filters, so it's slow, but it works fine.  

Pat

0 Kudos
Message 9 of 9
(3,773 Views)