/// <summary>
        /// Creates the instance and invoke method.
        /// </summary>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <param name="typeName">Name of the type.</param>
        /// <param name="constructorParameters">The constructor parameters.</param>
        /// <param name="method">The method.</param>
        /// <param name="methodParameters">The method parameters.</param>
        /// <returns>RemoteInvokeResult.</returns>
        public SandboxMarshalInvokeResult CreateInstanceAndInvokeMethod(string assemblyName, string typeName, object[] constructorParameters, string method, params object[] methodParameters)
        {
            SandboxMarshalInvokeResult result = new SandboxMarshalInvokeResult();

            try
            {
                assemblyName.CheckEmptyString(nameof(assemblyName));
                method.CheckEmptyString(nameof(method));

                TempAssembly assembly;
                if (tempAssemblies.TryGetValue(assemblyName, out assembly))
                {
                    var objectToRun = assembly.CreateInstance(typeName, constructorParameters);
                    objectToRun.CheckNullObject(nameof(objectToRun));

                    var methodInfo = objectToRun.GetType().GetMethod(method);
                    methodInfo.CheckNullObject(nameof(methodInfo));

                    result.SetValue(methodInfo.Invoke(objectToRun, methodParameters));
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                result.SetException(ex.Handle(new { typeName, method }));
            }

            return result;
        }
        /// <summary>
        /// Gets the API contracts.
        /// </summary>
        /// <returns>RemoteInvokeResult.</returns>
        public SandboxMarshalInvokeResult GetApiContracts()
        {
            SandboxMarshalInvokeResult result = new SandboxMarshalInvokeResult();

            try
            {
                Dictionary<string, string> interfaces = new Dictionary<string, string>();

                foreach (var one in EnvironmentCore.DescendingAssemblyDependencyChain)
                {
                    foreach (var item in one.GetTypes())
                    {
                        if (item.IsInterface && item.HasAttribute<ApiContractAttribute>() && !item.IsGenericTypeDefinition)
                        {
                            interfaces.Merge(item.GetFullName(), item.Name, false);
                        }
                    }
                }

                result.SetValue(interfaces);
            }
            catch (Exception ex)
            {
                result.SetException(ex.Handle());
            }

            return result;
        }
        /// <summary>
        /// Creates the instance and invoke method.
        /// </summary>
        /// <param name="typeFullName">Name of the type.</param>
        /// <param name="constructorParameters">The constructor parameters.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="methodParameters">The method parameters.</param>
        /// <returns>RemoteInvokeResult.</returns>
        /// <exception cref="InvalidObjectException"></exception>
        public SandboxMarshalInvokeResult CreateInstanceAndInvokeMethod(string typeFullName, object[] constructorParameters, string methodName, params object[] methodParameters)
        {
            SandboxMarshalInvokeResult result = new SandboxMarshalInvokeResult();

            try
            {
                typeFullName.CheckEmptyString(nameof(typeFullName));
                methodName.CheckEmptyString(nameof(methodName));

                var type = ReflectionExtension.SmartGetType(typeFullName);
                type.CheckNullObject(nameof(type));

                var instance = Activator.CreateInstance(type, (object[])constructorParameters);

                var methodInfo = type.GetMethod(methodName);
                methodInfo.CheckNullObject(nameof(methodInfo));

                if (methodInfo.IsStatic)
                {
                    throw new InvalidObjectException(nameof(methodName), data: methodName, reason: "Method is static");
                }

                result.SetValue(methodInfo.Invoke(instance, methodParameters));
            }
            catch (Exception ex)
            {
                result.SetException(ex.Handle(new { typeFullName, constructorParameters, methodName, methodParameters }));
            }

            return result;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SandboxInvokeResult"/> class.
 /// </summary>
 /// <param name="result">The result.</param>
 internal SandboxInvokeResult(SandboxMarshalInvokeResult result)
 {
     if (result != null)
     {
         this.Type = result.Type;
         this.ExceptionInfo = result.ExceptionInfo;
         this.Value = result.Value;
     }
 }
        /// <summary>
        /// Invokes the static method.
        /// </summary>
        /// <param name="typeName">Name of the type.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="methodParameters">The method parameters.</param>
        /// <returns>RemoteInvokeResult.</returns>
        /// <exception cref="InvalidObjectException"></exception>
        public SandboxMarshalInvokeResult InvokeStaticMethod(string typeName, string methodName, params object[] methodParameters)
        {
            SandboxMarshalInvokeResult result = new SandboxMarshalInvokeResult();

            try
            {
                typeName.CheckEmptyString(nameof(typeName));
                methodName.CheckEmptyString(nameof(methodName));

                var type = ReflectionExtension.SmartGetType(typeName);
                type.CheckNullObject(nameof(type));

                var methodInfo = type.GetMethod(methodName);
                methodInfo.CheckNullObject(nameof(methodInfo));

                if (!methodInfo.IsStatic)
                {
                    throw new InvalidObjectException(nameof(methodName), data: methodName, reason: "Method is not static");
                }

                result.SetValue(methodInfo.Invoke(null, methodParameters));
            }
            catch (Exception ex)
            {
                result.SetException(ex.Handle(new { typeName, methodName, methodParameters }));
            }

            return result;
        }