dotNetRDF and Unity: integration
My objective: Build an application for Windows10-64bit that uses Unity and dotNetRDF together to manage a Fuseki triple store. The same code works fine when used alone . I mean, in a Visual Studio console project.
.
My Problem is the error message:
System.InvalidOperationException: request started
at System.Net.HttpWebRequest.CheckRequestStarted () [0x00008] in :0
at System.Net.HttpWebRequest.set_Accept (System.String value) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest:set_Accept (string)
at VDS.RDF.Update.SparqlRemoteUpdateEndpoint.Update (System.String sparqlUpdate) [0x00111] in :0
at NewBehaviourScript.oneTriple () [0x00015] in C:\Users\Public\Documents\Unity Projects\OntSense3D\Assets\NewBehaviourScript.cs:40
UnityEngine.MonoBehaviour:print(Object)
NewBehaviourScript:oneTriple() (at Assets/NewBehaviourScript.cs:45)
UnityEngine.EventSystems.EventSystem:Update()
.
My environment:
Unity 2017.3 64bits
Scripting Runtime Version: Experimental (.NET 4.6 Equivalent)
Scripting Backend: Mono
API Compatible Level: .NET 4.6
.
dotNetRFD v2.0.1
This package was obtained with the use of Visual Studio Nuget. To make this dowload possible the Unity was configured as: API Compatible Level: .NET 4.6
The dlls associated with net40 were moved to the directory applets. In that way, there were recognized by Unity.
.
The Unity "game" consists of an single button that has the code provided below.
When I run the game and press the button (which "OnClick()" property is associated with the NewBehaviourScript.oneTriple() method), I get the error presented before.
.
Code of NewBehaviourScript class associated with the button:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OntSenseCSharpAPI;
using System;
using VDS.RDF.Query;
using VDS.RDF.Update;
public class NewBehaviourScript : MonoBehaviour {
private SparqlRemoteUpdateEndpoint endpoint;
// Use this for initialization
void Start() {
// Start access to Sparql End Point : in this case it is a Fuseki triple store
endpoint = new SparqlRemoteUpdateEndpoint("http://localhost:3030/test/update");
}
// Update is called once per frame
void Update() {
}
public void oneTriple() {
String updateCmd =
"PREFIX ontsense: < http://example.org/sense#> " +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
"INSERT DATA" +
" {" +
" ontsense: dotNetRDF rdf:comment \"dotNetRDF is a great tool.\"@en . " +
"}";
print(updateCmd); // What I want.
try
{
endpoint.Update(updateCmd);
}
catch (Exception e)
{
print(e); // The problem !
throw; // Re-throw the error.
}
}
}