From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

ServerVariable.Create - unable to create variable in vb.net

Solved!
Go to solution

Hi:

 

I'm trying to programatically create network variables instead of using the DSM utility. I try to do the following put get an exception when I try to do a connect.

 

               Dim svar_info As ServerVariableInfo = New ServerVariableInfo(m_Compponent_Name, "yPredict")

                If Not svar_info.Exists Then
                    Dim svo As ServerVariableInfo = ServerVariable.Create(m_Compponent_Name, "yPredict")
                    svar_info.VariableType = GetType(Double)
                End If

             

                Dim netvarLocation As String = "\\localhost\" + m_Compponent_Name + "\yPredict"
                yPredict_NVT = New NetworkVariable.NetworkVariableBufferedWriter(Of Double)(netvarLocation)

                'ypred_subscribe = NetworkVariableBufferedSubscriber(yPredictLocation)
                yPredict_NVT.Connect()    ----> exception occurs after this

 

regards,

 

Dan

 

 

0 Kudos
Message 1 of 5
(5,128 Views)

Hey Dan,

 

A few questions for you. First, we could try putting the Connect() call in a try-catch statement to see what the exception is, or run with debugging enabled to see exactly what that exception is. That should definitely help us track down the error.

 

Also, have you looked at the code examples that come with Measurement Studio? You can find them at Start > All Programs > National Instruments > Measurement Studio > .NET Examples. Under the Network Variable folder, there is a Creation example, and a folder with VB code. It might help to take a look at that and see if it clears up your questions.

 

Finally, if you open up the DSM utility after running your code, do you see the shared variable appear? I want to narrow down whether the problem is with creating the variable, or with subscribing to it, since you're getting the error at the subscription point. 

 

Hopefully these steps will help get us closer to a solution. Let me know the answers and we can work further on your problem!

0 Kudos
Message 2 of 5
(5,116 Views)

Hi Daniel:

 

There is a try catch around all those statements and it throws an item not found exception.

 

Can't seem to find the examples folder in my distribution. Can you direct where I can download them?

 

The DSM doesn't show any of the variables I'm trying to create.

 

Bets REgards,

 

Dan

 

ps: I just tried rebooting and noticed that all the variables are now present. Let me do some additional debuging. Would still like to see those examples.

0 Kudos
Message 3 of 5
(5,112 Views)
Solution
Accepted by topic author dbruchez

Hey Dan,

 

In Visual Studio, if you click on the Measurement Studio menu and choose "Measurement Studio Examples", it should take you to the folder of examples. Hopefully that will work, if not, it's possible that the examples weren't properly installed during the Measurement Studio installation, in which case you could run a repair install to ensure that those items are installed. I can walk you through that if it ends up being needed.

 

Good luck with the debugging!

0 Kudos
Message 4 of 5
(5,101 Views)

Hi Daniel:

 

Thanks, found them! Network variable engine seems to be behaving after reboot must of been in an odd state. Will keep an eye on it.

 

regards,

 

Dan

0 Kudos
Message 5 of 5
(5,098 Views)