ScxV6Server objServer

AussieBoy

Well-known member
Joined
Sep 7, 2020
Messages
78
Programming Experience
Beginner
Hi, I have some code that I saved in a text file. I would like to re use it.
However, I now get an error with this line - His.Interface.LoadDataValue(1, 192, DateTime.UtcNow, sampleGS);

Severity Code Description Project File Line Suppression State
Error CS1061 'object' does not contain a definition for 'LoadDataValue' and no accessible extension method 'LoadDataValue' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) DNP3FT C:\Users\Administrator\source\repos\DNP3FT\DNP3FT\Program.cs 183 Active

Is it to do with the .net frame work version?

I have
C#:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ScxV6DbClient;
using System.Diagnostics;


C#:
                ScxV6Server objServer = new ScxV6Server();
                objServer.Connect("Local", "admin", "admin");
                ScxV6Object obj = objServer.FindObject("xxx.xxx");
                ScxV6Aggregate His = obj.Aggregate["Historic"];

                for (int i = 1; i < 59; i++)
                {
                    //Write to history                           
                    His.Interface.LoadDataValue(1, 192, DateTime.UtcNow, sampleGS[i]);
                    obj = null;
                }

                objServer.Disconnect();
 
That suggests that His.Interface is type object and that, if the underlying object is some other type and you want to use it as that type, you need to cast it as that type. If you mouse over it in the code window, what does Intellisense tell you?
 
That suggests that His.Interface is type object and that, if the underlying object is some other type and you want to use it as that type, you need to cast it as that type. If you mouse over it in the code window, what does Intellisense tell you?
The same as the error message
 
Here's a text version of that documentation:


Section 7.1.4, which describes that ScxV6Aggregate.Interface property, does indeed specify that it is type Object, confirming exactly what I said and what the error message indicated in the first place. With no prior experience with this library, I was able to confirm exactly what the issue was with a web search and a quick read of some documentation. Hopefully this illustrates the steps you should be taking on your own behalf before posting a question, reserving such posts for the stuff that you can't work out for yourself.
 
FYI, the documentation includes example code that appears to be written in VB6. Lots of VB6 code relies on late binding, which means that the code refers to members that the compiler cannot confirm at compile time and thus are basically ignored and left until run time to be resolved. This is also possible in VB.NET if you set Option Strict Off but it is not supported in C#. That means that the C# code you posted could never have worked and must have just been a direct conversion from some VB code that you didn't analyse in order to understand properly in a C# context.
 
Back
Top Bottom