3

when moving from Gremlin.net 3.6.1, to 3.6.2 I get a FileNotFound Exception pointing to "rootOfProject"/Gremlin.net.dll This is happening in my startup.cs when instantiating the GremlinClient

services.AddSingleton<GremlinClient>(s =>
            {
                GremlinServer server = new GremlinServer(hostname: "host", port: 443, enableSsl: true, username: $"collection", password: "password"]);
                var connectionPoolSettings = new ConnectionPoolSettings
                {
                    MaxInProcessPerConnection = 32,
                    PoolSize = 4,
                    ReconnectionAttempts = 4,
                    ReconnectionBaseDelay = TimeSpan.FromSeconds(1)
                };

                var socket = new Action<ClientWebSocketOptions>(o =>
                {
                    o.KeepAliveInterval = TimeSpan.FromSeconds(10);
                });
            return new GremlinClient(server, new GraphSON2MessageSerializer(), connectionPoolSettings, socket);

I have tried to copy the Gremlin.net.dll to the root folder of the project. And then it works. I find it strange that the code is suddenly looking for the .dll at the root and not in the \bin folder

----------
{
    "developerMessage": "One or more errors occurred. (Could not find file 'C:\\SourceEquinor\\repos\\mad-vsm-api\\Equinor.Vsm.Api\\Gremlin.Net.dll'.)",
    "userMessage": "Server error, contact system responsible",
    "code": "500",
    "httpStatusCode": 500,
    "exception": {
        "ClassName": "System.AggregateException",
        "Message": "One or more errors occurred.",
        "Data": null,
        "InnerException": {
            "ClassName": "System.IO.FileNotFoundException",
            "Message": "Could not find file 'C:\\SourceEquinor\\repos\\mad-vsm-api\\Equinor.Vsm.Api\\Gremlin.Net.dll'.",
            "Data": null,
            "InnerException": null,
            "HelpURL": null,
            "StackTraceString": "   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)\r\n   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)\r\n   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)\r\n   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)\r\n   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)\r\n   at System.Reflection.Metadata.MetadataReader.GetAssemblyName(String assemblyFile)\r\n   at Gremlin.Net.Process.Utils.GenerateUserAgent()\r\n   at Gremlin.Net.Process.Utils.get_UserAgent()\r\n   at Gremlin.Net.Driver.WebSocketConnection..ctor(IClientWebSocket client, WebSocketSettings settings)\r\n   at Gremlin.Net.Driver.ConnectionFactory.CreateConnection()\r\n   at Gremlin.Net.Driver.ConnectionPool.CreateNewConnectionAsync()\r\n   at Gremlin.Net.Driver.ConnectionPool.FillPoolAsync()",
            "RemoteStackTraceString": null,
            "RemoteStackIndex": 0,
            "ExceptionMethod": null,
            "HResult": -2147024894,
            "Source": "System.Private.CoreLib",
            "WatsonBuckets": null,
            "FileNotFound_FileName": "C:\\SourceEquinor\\repos\\mad-vsm-api\\Equinor.Vsm.Api\\Gremlin.Net.dll",
            "FileNotFound_FusionLog": null
        },
        "HelpURL": null,
        "StackTraceString": "   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\r\n   at Gremlin.Net.Driver.ConnectionPool.FillPoolAsync()\r\n   at Gremlin.Net.Driver.ConnectionPool.ReplaceDeadConnectionsAsync()\r\n   at Gremlin.Net.Process.Utils.WaitUnwrap(Task task)\r\n   at Gremlin.Net.Driver.ConnectionPool..ctor(IConnectionFactory connectionFactory, ConnectionPoolSettings settings, ILogger`1 logger)\r\n   at Gremlin.Net.Driver.GremlinClient..ctor(GremlinServer gremlinServer, IMessageSerializer messageSerializer, ConnectionPoolSettings connectionPoolSettings, Action`1 webSocketConfiguration, String sessionId, Boolean disableCompression, ILoggerFactory loggerFactory)\r\n   at Equinor.Vsm.Api.Startup.<>c__DisplayClass7_0.<ConfigureServices>b__8(IServiceProvider s) in C:\\SourceEquinor\\repos\\mad-vsm-api\\Equinor.Vsm.Api\\Startup.cs:line 205\r\n   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)\r\n   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)\r\n   at MediatR.Wrappers.RequestHandlerWrapperImpl`2.<>c__DisplayClass1_0.<Handle>g__Handler|0()\r\n   at Equinor.Vsm.Api.Application.Behaviors.DiscardGraphCacheBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken) in C:\\SourceEquinor\\repos\\mad-vsm-api\\Equinor.Vsm.Api\\Application\\Behaviours\\DiscardGraphCacheBehavior.cs:line 23\r\n   at Equinor.Vsm.Api.Application.Behaviors.ValidationBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)\r\n   at Equinor.Vsm.Api.Controllers.V2.GraphController.MoveVertex(IGremlinQuerySource g, String projectId, MoveCommandDto moveCommand) in C:\\SourceEquinor\\repos\\mad-vsm-api\\Equinor.Vsm.Api\\Controllers\\V2\\GraphController.cs:line 88\r\n   at lambda_method30(Closure, Object)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)\r\n   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)\r\n   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)\r\n   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\r\n   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)",
        "RemoteStackTraceString": null,
        "RemoteStackIndex": 0,
        "ExceptionMethod": null,
        "HResult": -2146233088,
        "Source": "System.Private.CoreLib",
        "WatsonBuckets": null,
        "InnerExceptions": [
            {
                "ClassName": "System.IO.FileNotFoundException",
                "Message": "Could not find file 'C:\\SourceEquinor\\repos\\mad-vsm-api\\Equinor.Vsm.Api\\Gremlin.Net.dll'.",
                "Data": null,
                "InnerException": null,
                "HelpURL": null,
                "StackTraceString": "   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)\r\n   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)\r\n   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)\r\n   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)\r\n   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)\r\n   at System.Reflection.Metadata.MetadataReader.GetAssemblyName(String assemblyFile)\r\n   at Gremlin.Net.Process.Utils.GenerateUserAgent()\r\n   at Gremlin.Net.Process.Utils.get_UserAgent()\r\n   at Gremlin.Net.Driver.WebSocketConnection..ctor(IClientWebSocket client, WebSocketSettings settings)\r\n   at Gremlin.Net.Driver.ConnectionFactory.CreateConnection()\r\n   at Gremlin.Net.Driver.ConnectionPool.CreateNewConnectionAsync()\r\n   at Gremlin.Net.Driver.ConnectionPool.FillPoolAsync()",
                "RemoteStackTraceString": null,
                "RemoteStackIndex": 0,
                "ExceptionMethod": null,
                "HResult": -2147024894,
                "Source": "System.Private.CoreLib",
                "WatsonBuckets": null,
                "FileNotFound_FileName": "C:\\SourceEquinor\\repos\\mad-vsm-api\\Equinor.Vsm.Api\\Gremlin.Net.dll",
                "FileNotFound_FusionLog": null
            }
        ]
    }
}
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
  • Please provide the full exception message, stack trace, and any inner exceptions that happened. – mason Mar 15 '23 at 13:59
  • I'm having the same issue after upgrading to 3.6.2 version and calling Web.Api. The error message: `System.IO.FileNotFoundException: Could not load file or assembly "...\my-project\src\WebApi\Gremlin.Net.dll". The system cannot find the file specified`. – Mr. Blond Mar 20 '23 at 07:50
  • I guess it only happens when you run the application from Visual Studio. @Andreas did you find a way how to fix it? – Deniss Nest Mar 20 '23 at 09:34
  • No, I have not found a solution to fix it, other than to downgrade to 3.6.1 – Andreas Herigstad Mar 20 '23 at 09:47
  • Please also share your `csproj` file. Do you also get this error if your create a completely new project without any other dependencies and then add Gremlin.Net there? – Florian Hockmann Mar 22 '23 at 13:04
  • yes, I get it on a new project as well... – Andreas Herigstad Mar 24 '23 at 08:32

2 Answers2

2

Watch https://github.com/apache/tinkerpop/pull/2005. When it gets merged, the next release will contain a fix.

Daniel C. Weber
  • 1,011
  • 5
  • 12
0

If you really need the functionality of 3.6.2 release, one way would be to add copy command inside .csproj file. This is a temporary solution while you wait for the next Gremlin version. This issue only seems to happen for local environment, so could write something like this:

<Target Name="CopyDependencies" AfterTargets="Build">
<Copy Condition="$(ASPNETCORE_ENVIRONMENT) == 'local'" SourceFiles="$(OutDir)Gremlin.Net.dll" DestinationFolder="$(ProjectDir)" SkipUnchangedFiles="false" />
</Target>

Note that you need to add the environment variable ASPNETCORE_ENVIRONMENT: local as well. The value you decide yourself, either it's local, development etc.

After that is done, add Gremlin.Net.dll file to the .gitignore, so that it is not tracked via source control.

Mr. Blond
  • 1,113
  • 2
  • 18
  • 41