问题标签 [clearscript]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
504 浏览

javascript - 如何在 Clearscript 中序列化已编译的 V8Script?

我正在使用 ClearScript 编译一些 JavaScript,然后我想将其序列化以将其存储在 SQL 中。但是它被标记为不可序列化,我该怎么办?

我收到此错误:

0 投票
1 回答
186 浏览

javascript - 如何将 HtmlAgilityPack.CssSelectors 公开到 ClearScript

上下文:Azure、C#、ClearScript、JavaScript、HtmlAgilityPackHtmlAgilityPack.CssSelectors

我经常这样做:使用 ClearScript 向 C# 应用程序添加脚本。通常这只是工作。

然后,在 JavaScript 代码本身中,有类似的东西

所以在我加入之前,一切都很顺利HtmlAgilityPack.CssSelectors。在 C# 方面,这为HtmlDocument对象添加了额外的方法,特别是QuerySelectorQuerySelectorAll. 它们在 C# 端可见。然而,在 JavaScript 方面,它们不是,代码如

引发错误并从 Visual Studio 2015 中的调试会话中查看对象显示QuerySelectorhap var 中没有方法。

那么故事是什么?是 ClearScript 问题还是 C# 问题?我该怎么办?我很高兴编写一个包装类,我只是希望一切都能像以前一样工作。

0 投票
1 回答
459 浏览

javascript - 如何在 C# Selenium 中向 FirefoxDriverService 添加配置文件规范?

上下文:Azure、C#、ClearScript、Selenium、Firefox

我将 Selenium 的 Firefox 符号公开到 ClearScript JavaScript 环境中。在以下 JavaScript 代码中,从 C# 公开/导出的符号以 CS 为前缀。

目前我不支持配置文件,但想以某种方式添加它们。如何在 FirefoxDriverService 的上下文中指定配置文件?

0 投票
1 回答
677 浏览

c# - How to invoke method of dynamic object using reflection

I've got dynamic object which contains some execute function generated by V8ScriptEngine. I need to execute this method with parameters which was specified in Dictionary object. I tried this approach:

but it throws

TypeError: Method or property not found

I also tried scriptObject.GetType().GetMethod("execute").Invoke with the same result But if i try to execute it manually (e.g scriptObject.execute(1,2)) it will return valid result. How can i invoke this method dynamically?

0 投票
1 回答
295 浏览

c# - 作为服务运行时的装配错误

当我将我的应用程序作为服务运行时,我遇到了一个汇编错误。每当我直接从 Visual Studio 启动项目时,都不会发生这种情况。以下是完整的错误信息。似乎错误是这样的:

比较程序集名称导致不匹配:PUBLIC KEY TOKEN

任何人都知道这PUBLIC KEY TOKEN是什么以及如何解决这个问题?

0 投票
1 回答
167 浏览

c# - ClearScript 中的重载运算符

我正在尝试使用自定义运算符对我的应用程序中的自定义类进行算术运算,该应用程序与ClearScript接口。下面是我的示例自定义类的片段:

我的 ClearScript 引擎已正确初始化,我可以通过 Javascript 正确初始化Vector3对象,并相应地修改属性。

但是,如果我在 Javascript 环境中初始化 2 个Vector3对象,并尝试使用 Javascript 加法运算符,它最终会将加法运算符评估为字符串连接,而不是我的自定义运算符。

例子:

变量c只包含string( [object HostObject][object HostObject]),而不是Vector3对象。

如何让 Javascript 引擎知道调用我的自定义运算符,而不是使用 ClearScript 使用默认的 Javascript 运算符?

0 投票
1 回答
122 浏览

c# - 释放父 V8Runtime 时是否释放 V8ScriptEngine 实例?

释放父 V8Runtime 时是否释放 V8ScriptEngine 实例?

该库的文档对此尚不清楚。我已经实现了部分 CommonJS 环境,但我想确保最终处理V8ScriptEngine使用 s 创建的实例。require()

0 投票
1 回答
2621 浏览

c# - 无法使用 ClearScript.V8 加载程序集或依赖项

我用 ClearScript.V8 开始了一个项目。我正在使用 C# 在 Windows 10 和 Visual Studio 2015 上进行开发。Web 是 IISExpress,最终将在 Windows 2012 服务器上发布。我使用 NuGet 添加了包 ClearScript.V8 (v5.4.9)。我总是从一开始就收到下面的错误,甚至还没有初始化 ClearScript(是的,它是法语,但应该很容易理解):

Impossible de Charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances。Le module spécifié est introuvable。

描述 : Une exception non gérée s'est produite au moment de l'exécution de la requête Web actuelle。Contrôlez la trace de la pour pour plus d'informations sur l'erreur et son origine dans le code。

异常的详细信息:System.IO.FileNotFoundException: Impossible de Charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances。Le module spécifié est introuvable。

错误来源:

Une exception non gérée s'est produite lors de l'execution de la requête Web actuelle。Les informations relatives à l'origin et l'emplacement de l'exception peuvent être identifiées en utilisant la trace de la pile d'exception ci-dessous。

跟踪 de la pile:

[FileNotFoundException: Impossible de Charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances。Le module spécifié est introuvable.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly。 nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean suppressSecurityChecks) +36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark & stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMarkString & , IntPtr pPrivHostBinder, Boolean for Introspection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21 System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Impossible de Charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances。Le module spécifié est introuvable.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai ) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, 异常 appDomainCreationException) +549

[HttpException (0x80004005): Impossible de Charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances。Le module spécifié est introuvable.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10044576 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

版本信息:Microsoft .NET Framework 版本:4.0.30319;版本 ASP.NET:4.7.2046.0

我按照https://microsoft.github.io/ClearScript/Details/Build.html(尤其是第四节)的说明进行操作,所以我有文件 ClearScript.dll、ClearScriptV8-32.dll、ClearScriptV8-64.dll、v8-ia32 .dll 和 v8-x64.dll 在我的 bin 文件夹中。我的根文件夹中也有 ClearScriptV8-32.dll 和 ClearScriptV8-64.dll(复制到输出 = 不要复制)。

我错过了什么?

0 投票
1 回答
475 浏览

c# - 如何在 ClearScript.V8 中捕获更新事件?

有没有办法我可以实例化一个 Javascript 变量(使用 ClearScript.V8)并在 C# 中捕获更新,以便我可以更新数据库中的值?

它在我使用对象时起作用,如下所示:

但随后 Javascript 代码需要使用类似的对象

变量.值

而不是简单地

多变的

.

0 投票
1 回答
219 浏览

javascript - v8ScriptEngine 如何推断脚本语言

只是好奇,刚开始使用V8ScriptEngine,我有这个代码片段

这很好用..

脚本引擎如何推断脚本语言是 Javascript?,我想它必须评估整个脚本块来断言它是 java 还是 vb 或任何其他受支持的语言,这不是一项昂贵的任务吗?或者是否可以告诉 Scriptengine 语言目标具有特定的风格?