Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-14-2021 07:21 PM
I have some old Powershell scripts that use the v1.7 driver. I am trying to move them to v4 but cannot seem to get the synchronous classes.
When I call Session() I am hitting the the Async implementation instead of the synchronous, even though I have loaded the Simple DLL.
Error:
Cannot find an overload for "Session" and the argument count: "0".
OverloadDefinitions
-------------------
Neo4j.Driver.Internal.IInternalAsyncSession, Neo4j.Driver, Version=4.2.37.0, Culture=neutral, PublicKeyToken=null Session(System.Action[Neo4j.Driver.SessionConfigBuilder] action, bool reactive)
Full sample code below:
param
(
[Parameter(Mandatory = $false)] [string] $boltUri = $env:BOLT_URI
, [Parameter(Mandatory = $false)] [string] $username = $env:BOLT_USERNAME
, [Parameter(Mandatory = $false)] [string] $password = $env:BOLT_PASSWORD
, [Parameter(Mandatory = $false)] [string] $query = @"
MATCH (g) RETURN g LIMIT 5
"@
)
$basePath = "$env:LOCALAPPDATA\PackageManagement\NuGet\Packages"
# Have to load assembly before you can reference it
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/dff8487f-69af-4b64-ab83-13d58a55c523/addtype-inheritance-loaderexceptions?forum=winserverpowershell
Add-Type -LiteralPath "$basePath\neo4j.Driver.4.2.0\lib\netstandard2.0\Neo4j.Driver.dll"
Add-Type -LiteralPath "$basePath\Neo4j.Driver.Simple.4.2.0\lib\netstandard2.0\Neo4j.Driver.Simple.dll" -ReferencedAssemblies "$basePath\neo4j.Driver.4.2.0\lib\netstandard2.0\Neo4j.Driver.dll"
$authToken = [Neo4j.Driver.AuthTokens]::Basic($username,$password)
if(!($dbDriver = [Neo4j.Driver.GraphDatabase]::Driver($boltUri,$authToken)))
{
Write-Warning ("Could not establish session with {0}" -f $boltUri)
}
$session = $dbDriver.Session()
$r = $session.Run($query)
$session = $null
$dbDriver = $null
04-14-2021 07:29 PM
Instead of this v1.7 syntax
$session = $dbDriver.Session()
use :
$session = [Neo4j.Driver.DriverExtensions]::Session($dbDriver)
04-15-2021 05:31 AM
@hkelley did you answer your own question?
If so, thanks for coming back and posting the solution! So often people forget to do that (myself included).
All the sessions of the conference are now available online