LOGIN  |  REGISTER
Smart Living Made Brilliant!
CASTLEOS FORUM

HomeBug Reports

A forum topic for reporting bugs and other issues with CastleOS

Do scripts actually get run? Messages in this topic - RSS

Tommy Long
Tommy Long
Posts: 190


17 days ago
Tommy Long
Tommy Long
Posts: 190
Using 1.3.3170. Have set up a scene that is suppose to run a script. The Log indicates it runs the script, but can't find any evidence that the script was actually executed. The following script did not speak, nor write a log entry.


using System;
using System.Collections.Generic;
using CastleOSCoreService;



public class MyScript
{


public void Main(string[] args)
{
// This method call will create a database entry in the main log. You can write anything you'd
// like here and it will add it to the DB queue for logging. Queue operates as first in first out.

ScriptingAPI.WriteDatabaseEntry("This is a test database entry.");

// This method call will speak the text of your choice to the speaker of your choice.
// You'll notice two strings, the first is the text to be spoken, and the second is the ID
// of the speaker to speak through. By default, enter "all" to speak to any connected or
// detected speaker. But you can also specify the speaker, as we'll show in the next section.

ScriptingAPI.Speak("This is a demo announcement to all speakers.", "all");

}
}
0 link
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3261


15 days ago
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3261
Hi Tommy, is that database entry getting logged, that says "This is a test database entry."? If so, that confirms your script has run. If there is nothing in the log, then check the error log for any issues that came up. But yes, it should be running normally...
0 link
Tommy Long
Tommy Long
Posts: 190


15 days ago
Tommy Long
Tommy Long
Posts: 190
Ah yes, there is an error in the error log: `CastleOSCoreService.ScriptingAPI' does not contain a definition for `WriteDatabaseEntry'
0 link
Tommy Long
Tommy Long
Posts: 190


15 days ago
Tommy Long
Tommy Long
Posts: 190
A related question, I have a much larger script that I tried to run under CastleOS and it too shows up as errors in the error log, but about the only indication I get is a compile error. I developed the script on a different machine with Visual studio 2017 and it works. So I'm thinking there may be a diffferent compiler and maybe different .NET Framework. What version C# compiler and .NET Framework does CastleOS use for running scripts?
0 link
Tommy Long
Tommy Long
Posts: 190


11 days ago
Tommy Long
Tommy Long
Posts: 190
I added the directive using CastleOS_API. The error log says it can't find it, asking if I'm missing an assembly directive. Does this mean I need to add the CastleOS_API.dll somewhere and if so, where would I put it?
0 link
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3261


11 days ago
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3261
Tommy Long wrote:
A related question, I have a much larger script that I tried to run under CastleOS and it too shows up as errors in the error log, but about the only indication I get is a compile error. I developed the script on a different machine with Visual studio 2017 and it works. So I'm thinking there may be a diffferent compiler and maybe different .NET Framework. What version C# compiler and .NET Framework does CastleOS use for running scripts?



The script itself can't necessarily use everything in .NET. Can you post it so I can see what might be in conflict? Or send it to me privately?
0 link
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3261


11 days ago
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3261
Tommy Long wrote:
I added the directive using CastleOS_API. The error log says it can't find it, asking if I'm missing an assembly directive. Does this mean I need to add the CastleOS_API.dll somewhere and if so, where would I put it?



CastleOS_API is a class, not a namespace, so you can't list it like that. But I realized the issue with the method that it couldn't find is that it changed to LogEventToDatabase. I'll update the demo scripts accordingly...
0 link
Tommy Long
Tommy Long
Posts: 190


11 days ago
Tommy Long
Tommy Long
Posts: 190
Chris Cicchitelli wrote:
Tommy Long wrote:
A related question, I have a much larger script that I tried to run under CastleOS and it too shows up as errors in the error log, but about the only indication I get is a compile error. I developed the script on a different machine with Visual studio 2017 and it works. So I'm thinking there may be a diffferent compiler and maybe different .NET Framework. What version C# compiler and .NET Framework does CastleOS use for running scripts?



The script itself can't necessarily use everything in .NET. Can you post it so I can see what might be in conflict? Or send it to me privately?



The error is "error CS0433: The imported type `System.Net.HttpWebRequest' is defined multiple times".
This is a type I use in my script.

The directives in my script are:

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
using System.Threading;


I commented out //using System.Net.Sockets and //using System.Net and the error still did not go away.
0 link