Search code examples
c#virtuosodotnetrdf

Connect to Virtuoso with DotNetRDF


I try to connect to my Virtuoso Server with dotnetrdf. There is an example in the documentation that goes like ...

//Create our Storage Provider - this example uses Virtuoso Universal Server
VirtuosoManager virtuoso = new VirtuosoManager("https://myhost.org", 1111, "DB", "username", "password");

//Load the Graph into an ordinary graph instance first
Graph g = new Graph();
virtuoso.LoadGraph(g, new Uri("http://example.org/"));

I replaced username and password with my credentials, but when it comes to the virtuoso.LoadGraph line, I get a FormatException that says:

The input string has the wrong format with the following stacktrace:

bei System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
bei System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
bei OpenLink.Data.Virtuoso.TcpConnection.GetEndPoint(String ds)
bei OpenLink.Data.Virtuoso.TcpConnection.Open(ConnectionOptions options)
bei OpenLink.Data.Virtuoso.VirtuosoConnection.CreateInnerConnection(ConnectionOptions options, Boolean enlist)
bei OpenLink.Data.Virtuoso.ConnectionPool.GetConnection(ConnectionOptions options, VirtuosoConnection connection)
bei OpenLink.Data.Virtuoso.VirtuosoConnection.Open()
bei VDS.RDF.Storage.VirtuosoManager.Open(Boolean keepOpen, IsolationLevel level)
bei VDS.RDF.Storage.VirtuosoManager.LoadGraph(IRdfHandler handler, Uri graphUri)
bei VDS.RDF.Storage.VirtuosoManager.LoadGraph(IGraph g, Uri graphUri)
bei VirtuosoTest.MainWindow.LoadGraph() in C:\Users\devfs\Documents\Visual Studio 2015\Projects\Test\VirtuosoTest\VirtuosoTest\MainWindow.xaml.cs:Zeile 40.
bei VirtuosoTest.MainWindow..ctor() in C:\Users\devfs\Documents\Visual Studio 2015\Projects\Test\VirtuosoTest\VirtuosoTest\MainWindow.xaml.cs:Zeile 30.

Unfortunately, this doesn't help much when trying to figure out what might be wrong. Any idea, what I can do to narrow down the problem?

PS: I can access the Virtuoso conductor via https://myhost.org:8890/conductor and I also tried the port 8890 as parameter (but I think this is not the needed port) with the same result. If I omit the port, I get the error, that the target computer refuses the connection.

Thanks in advance,
Frank


Solution

  • Your issue lies here --

    VirtuosoManager("https://myhost.org", 1111, "DB", "username", "password");
    

    The dotnetrdf connection is not via http/https; the first argument should just be a hostname, i.e., myhost.org.

    Simply changing the above to the following should resolve the immediate error --

    VirtuosoManager("myhost.org", 1111, "DB", "username", "password");