Ejemplo n.º 1
0
        public void BadV8Deployment_NoNativeLibrary()
        {
            GC.Collect();

            V8Proxy.RunWithDeploymentDir("BadV8Deployment_NoNativeLibrary", () =>
            {
                var moduleNotFoundException       = new Win32Exception(126 /*ERROR_MOD_NOT_FOUND*/);
                TypeLoadException caughtException = null;

                try
                {
                    using (new V8ScriptEngine())
                    {
                    }
                }
                catch (TypeLoadException exception)
                {
                    caughtException = exception;
                }
                catch (TargetInvocationException exception)
                {
                    if (exception.InnerException is TypeLoadException typeLoadException)
                    {
                        caughtException = typeLoadException;
                    }
                    else
                    {
                        throw;
                    }
                }

                Assert.IsNotNull(caughtException);
                Assert.IsTrue(caughtException.Message.Contains(moduleNotFoundException.Message));
            });
        }
Ejemplo n.º 2
0
        public static void Destroy(ref V8EntityHolder holder)
        {
            var tempHandle = holder.handle;

            if (tempHandle != V8Entity.Handle.Empty)
            {
                V8SplitProxyNative.InvokeNoThrow(instance => instance.V8Entity_DestroyHandle(tempHandle));
            }

            if (holder.registered)
            {
                V8Proxy.OnEntityHolderDestroyed();
            }

            holder = new V8EntityHolder(holder.name);
        }
Ejemplo n.º 3
0
        public void BadV8Deployment_NoNativeLibrary()
        {
            V8Proxy.RunWithDeploymentDir("BadV8Deployment_NoNativeLibrary", () =>
            {
                var testException = new Win32Exception(126 /*ERROR_MOD_NOT_FOUND*/);
                TypeLoadException caughtException = null;

                try
                {
                    using (new V8ScriptEngine())
                    {
                    }
                }
                catch (TypeLoadException exception)
                {
                    caughtException = exception;
                }

                Assert.IsNotNull(caughtException);
                // ReSharper disable once PossibleNullReferenceException
                Assert.IsTrue(caughtException.Message.Contains(testException.Message));
            });
        }
Ejemplo n.º 4
0
 public V8EntityHolder(string name, Func <V8Entity.Handle> acquireHandle)
 {
     this.name  = name;
     registered = V8Proxy.OnEntityHolderCreated();
     handle     = acquireHandle();
 }