Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Showcase


Channel Catalog


Channel Description:

ClearScript is a library that makes it easy to add scripting to your .NET applications. It currently supports JavaScript (via V8 and JScript) and VBScript.

older | 1 | .... | 94 | 95 | (Page 96) | 97 | 98 | .... | 115 | newer

    0 0

    Hi Guys, this is a simple issue but I cannot get it to work. I need to create a byte array on the javascript side but I´m getting the following error depending on the type I use:

    byte is not a function


    I´ve tried the following:

    var message = new byte[4096];
    var message = new System.Byte[4096];
    var message = host.newVar(System.Byte[4096]);

    Obviously I am doing something wrong and clearscript works differentrly with arrays.

    Can someone help me?. Thanks.

    0 0

    Also tried:

    var message = new host.newArr(byte, 4096);
    var message = new host.newArr(System.Byte, 4096);

    But I get 'Invalid constructor invocation'

    0 0

    Sorry, my mistake.... the correct line was:

    var message = host.newArr(System.Byte, 4096);

    0 0

    Hello,

    Yes, that's probably the most generic and straightforward way to do it. And if you'd prefer not to expose HostFunctions or the array element type, you could always provide a custom array factory for your scenario.

    Cheers!

    0 0

    5.4.5
    • Breaking Change: Added strongly-typed indexing support for IList<T>. Because IList<T> takes precedence over IList, array and list elements retrieved by index are now correctly type-restricted. Use the new propertyScriptEngine.DisableListIndexTypeRestriction to restore the previous behavior, orScriptEngine.DisableTypeRestriction to control type restriction globally.
    • Added V8ScriptEngine.SuppressExtensionMethodEnumeration (Issue #101).
    • Fixed native property hiding on V8 (Issue #98).
    • Fixed host method clobbering on V8.
    • Reduced V8 stack overflow detection false positives.
    • Added HostItemFlags.DirectAccess.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 4.9.385.30.

    5.4.4
    • Added fast data transfer between host arrays and JavaScript typed arrays (and other ArrayBuffer views) (Issue #83).
    • IEnumerable instances now supportES6 iteration andfor...of when exposed inV8ScriptEngine.
    • Added fully dynamic treatment for exposed IDispatchEx instances (Issue #96).
    • Fixed host member enumeration and deletion on JScript with Standards Mode (Issue #94).
    • Improved numeric argument conversion and matching (Issue #95).
    • Fixed nested termination behavior on V8.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 4.7.80.25.

    5.4.3
    • Added support for Visual Studio 2015.
    • Changed V8Update to use installed Python 2.x.
    • Fixed hangs in V8 proxy finalizers during script execution (Issue #86).
    • Fixed V8 weak handle callback context leak (Issue #90).
    • Fixed dynamic method invocation with value-typed arguments (Issue #89).
    • Improved V8ScriptEngine.Interrupt() latency and reliability.
    • Added tests for bug fixes.
    • Tested with V8 4.4.63.29.

    5.4.2.1
    • Fixed unnecessary assembly table construction (Issue #84).

    5.4.2
    • Updated ClearScriptBenchmarks to use SunSpider 1.0.2.
    • Host methods and delegates in V8ScriptEngine now supporttoFunction(), which creates a native JavaScript function wrapper.
    • Fixed syntax error reporting in nested WindowsScriptEngine invocations.
    • Added defensive code to tolerate IProcessDebugManager::AddApplication() failure (Issue #76).
    • Added ScriptEngine.AddHostType() overloads that derive the script item name from the type name.
    • Implemented host item data sharing and other optimizations, boosting memory efficiency in many scenarios.
    • Added default ScriptAccess settings at the type, assembly, and engine levels.
    • Enhanced support for default properties, fixing Issue #74.
    • Added IHostWindow and WindowsScriptEngine.HostWindow (Issue #73).
    • V8RuntimeConstraints limits are now specified inMiB. For compatibility with hosts that predate an inadvertent breaking change in Version 5.4.1, values greater than 1048576 (1TiB) are still interpreted as bytes.
    • Fixed V8 debug agent in ASP.NET and eliminated excessive thread usage (Issue #75).
    • Added ScriptMemberFlags.WrapNullResult, ScriptEngine.EnableNullResultWrapping, and HostFunctions.isNull() (Issue #72).
    • Added enforcement of restricted access to non-public accessors of public properties (Issue #71).
    • (Andrey Taritsyn) Switched assembly targets to .NET 4 Client Profile.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 4.2.77.18.

    5.4.1
    • Fixed several issues affecting GlobalMembers on V8.
    • Implemented a V8 debug agent to compensate for removed V8 API.
    • V8Update now fetches V8 source and dependencies from Git repositories.
    • Fixed V8 assembly unloading and patched V8 to tolerate redundant initialization (Issue #60).
    • Added ScriptEngine.EnableAutoHostVariables.
    • Fixed by-reference arguments to VBScript functions (Issue #58).
    • Removed support for Visual Studio 2012 (V8 build now requires at least Visual Studio 2013).
    • Added explicit loading of primary interop assemblies to fix Issue #68.
    • Added host exception marshaling for V8.
    • Fixed V8ScriptEngine crash when script code calls theHostObject constructor.
    • Fixed host item caching for host variables.
    • Added non-generic overloads of newArr() andfunc() to HostFunctions.
    • Added ScriptEngine.Current.
    • HostFunctions instances can now be exposed in multiple script engines.
    • Added a GetDynamicMemberNames() override toMetaScriptItem (Issue #64).
    • Fixed indexed property binding ambiguity for inherited interfaces (Issue #69).
    • Added tests for bug fixes and new APIs.
    • Tested with V8 3.30.33.16.

    5.4.0
    • Added COM object projection (Issue #38):
      • New ScriptEngine methods: AddCOMObject() and AddCOMType().
      • New ExtendedHostFunctions methods: newComObj() and comType().
    • Improved performance and memory usage:
      • Host methods, events, and const/readonly fields are now cached as direct V8 object properties.
      • Added shared bind cache for improved performance and enhanced binder leak mitigation.
      • Made V8ScriptEngine.CollectGarbage() much more aggressive.
      • Switched to weak context/isolate bindings for V8 script objects and compiled scripts, fixingIssue #44.
      • Bypassed reflection for Windows script item property and method access, fixingIssue #47.
      • Added explicit disposal of cached V8 objects to fix Issue #48.
    • Enhanced support for legacy scripts:
      • Added null, decimal, and array marshaling options to WindowsScriptEngine.
      • Added ScriptEngine.UseReflectionBindFallback.
      • VBScript's For Each ... Next and JScript's Enumerator now operate on IEnumerable instances.
    • Other enhancements:
      • Added optional heap size monitoring to V8ScriptEngine andV8Runtime (experimental).
      • Added HostFunctions.tryCatch().
      • Added ScriptEngine.Invoke() and V8ScriptEngine.Execute(V8Script).
      • Added ScriptEngine.DisableTypeRestriction.
      • Enhanced error reporting for V8 assembly load failures (Issue #39).
      • V8Update now supports branched V8 revisions.
    • Miscellaneous fixes:
      • Added a V8 array buffer allocator, fixing Issue #46.
      • Overhauled ClearScriptV8 string usage to fix Issue #42 and improve performance.
      • Hardened ClearScriptV8 smart pointers.
      • Changed ActiveScript sites to return the current thread culture.
      • Added defensive code to make V8-related API objects resurrection-safe, fixingIssue #51.
      • Fixed exception when using WindowsScriptEngineFlags.EnableDebugging with no suitable script debugger installed (Issue #36).
    • Updates for breaking V8 API changes.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 3.26.31.15.

    0 0

    5.4.5
    • Breaking Change: Added strongly-typed indexing support for IList<T>. Because IList<T> takes precedence over IList, array and list elements retrieved by index are now correctly type-restricted. Use the new property ScriptEngine.DisableListIndexTypeRestriction to restore the previous behavior, or ScriptEngine.DisableTypeRestriction to control type restriction globally.
    • Added V8ScriptEngine.SuppressExtensionMethodEnumeration (Issue #101).
    • Fixed native property hiding on V8 (Issue #98).
    • Fixed host method clobbering on V8.
    • Reduced V8 stack overflow detection false positives.
    • Added HostItemFlags.DirectAccess.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 4.9.385.30.

    5.4.4
    • Added fast data transfer between host arrays and JavaScript typed arrays (and other ArrayBuffer views) (Issue #83).
    • IEnumerable instances now support ES6 iteration and for...of when exposed in V8ScriptEngine.
    • Added fully dynamic treatment for exposed IDispatchEx instances (Issue #96).
    • Fixed host member enumeration and deletion on JScript with Standards Mode (Issue #94).
    • Improved numeric argument conversion and matching (Issue #95).
    • Fixed nested termination behavior on V8.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 4.7.80.25.

    5.4.3
    • Added support for Visual Studio 2015.
    • Changed V8Update to use installed Python 2.x.
    • Fixed hangs in V8 proxy finalizers during script execution (Issue #86).
    • Fixed V8 weak handle callback context leak (Issue #90).
    • Fixed dynamic method invocation with value-typed arguments (Issue #89).
    • Improved V8ScriptEngine.Interrupt() latency and reliability.
    • Added tests for bug fixes.
    • Tested with V8 4.4.63.29.

    5.4.2.1
    • Fixed unnecessary assembly table construction (Issue #84).

    5.4.2
    • Updated ClearScriptBenchmarks to use SunSpider 1.0.2.
    • Host methods and delegates in V8ScriptEngine now support toFunction(), which creates a native JavaScript function wrapper.
    • Fixed syntax error reporting in nested WindowsScriptEngine invocations.
    • Added defensive code to tolerate IProcessDebugManager::AddApplication() failure (Issue #76).
    • Added ScriptEngine.AddHostType() overloads that derive the script item name from the type name.
    • Implemented host item data sharing and other optimizations, boosting memory efficiency in many scenarios.
    • Added default ScriptAccess settings at the type, assembly, and engine levels.
    • Enhanced support for default properties, fixing Issue #74.
    • Added IHostWindow and WindowsScriptEngine.HostWindow (Issue #73).
    • V8RuntimeConstraints limits are now specified in MiB. For compatibility with hosts that predate an inadvertent breaking change in Version 5.4.1, values greater than 1048576 (1 TiB) are still interpreted as bytes.
    • Fixed V8 debug agent in ASP.NET and eliminated excessive thread usage (Issue #75).
    • Added ScriptMemberFlags.WrapNullResult, ScriptEngine.EnableNullResultWrapping, and HostFunctions.isNull() (Issue #72).
    • Added enforcement of restricted access to non-public accessors of public properties (Issue #71).
    • (Andrey Taritsyn) Switched assembly targets to .NET 4 Client Profile.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 4.2.77.18.

    5.4.1
    • Fixed several issues affecting GlobalMembers on V8.
    • Implemented a V8 debug agent to compensate for removed V8 API.
    • V8Update now fetches V8 source and dependencies from Git repositories.
    • Fixed V8 assembly unloading and patched V8 to tolerate redundant initialization (Issue #60).
    • Added ScriptEngine.EnableAutoHostVariables.
    • Fixed by-reference arguments to VBScript functions (Issue #58).
    • Removed support for Visual Studio 2012 (V8 build now requires at least Visual Studio 2013).
    • Added explicit loading of primary interop assemblies to fix Issue #68.
    • Added host exception marshaling for V8.
    • Fixed V8ScriptEngine crash when script code calls the HostObject constructor.
    • Fixed host item caching for host variables.
    • Added non-generic overloads of newArr() and func() to HostFunctions.
    • Added ScriptEngine.Current.
    • HostFunctions instances can now be exposed in multiple script engines.
    • Added a GetDynamicMemberNames() override to MetaScriptItem (Issue #64).
    • Fixed indexed property binding ambiguity for inherited interfaces (Issue #69).
    • Added tests for bug fixes and new APIs.
    • Tested with V8 3.30.33.16.

    5.4.0
    • Added COM object projection (Issue #38):
      • New ScriptEngine methods: AddCOMObject() and AddCOMType().
      • New ExtendedHostFunctions methods: newComObj() and comType().
    • Improved performance and memory usage:
      • Host methods, events, and const/readonly fields are now cached as direct V8 object properties.
      • Added shared bind cache for improved performance and enhanced binder leak mitigation.
      • Made V8ScriptEngine.CollectGarbage() much more aggressive.
      • Switched to weak context/isolate bindings for V8 script objects and compiled scripts, fixing Issue #44.
      • Bypassed reflection for Windows script item property and method access, fixing Issue #47.
      • Added explicit disposal of cached V8 objects to fix Issue #48.
    • Enhanced support for legacy scripts:
      • Added null, decimal, and array marshaling options to WindowsScriptEngine.
      • Added ScriptEngine.UseReflectionBindFallback.
      • VBScript's For Each ... Next and JScript's Enumerator now operate on IEnumerable instances.
    • Other enhancements:
      • Added optional heap size monitoring to V8ScriptEngine and V8Runtime (experimental).
      • Added HostFunctions.tryCatch().
      • Added ScriptEngine.Invoke() and V8ScriptEngine.Execute(V8Script).
      • Added ScriptEngine.DisableTypeRestriction.
      • Enhanced error reporting for V8 assembly load failures (Issue #39).
      • V8Update now supports branched V8 revisions.
    • Miscellaneous fixes:
      • Added a V8 array buffer allocator, fixing Issue #46.
      • Overhauled ClearScriptV8 string usage to fix Issue #42 and improve performance.
      • Hardened ClearScriptV8 smart pointers.
      • Changed ActiveScript sites to return the current thread culture.
      • Added defensive code to make V8-related API objects resurrection-safe, fixing Issue #51.
      • Fixed exception when using WindowsScriptEngineFlags.EnableDebugging with no suitable script debugger installed (Issue #36).
    • Updates for breaking V8 API changes.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 3.26.31.15.

    0 0

    Hi again,

    By the way, if you're using V8 for heavy-duty byte array manipulation in JavaScript, consider using Uint8Array. Doing so should provide an enormous performance advantage over using a managed array from script code, and ClearScript (since Version 5.4.4) supports fast data transfer between managed arrays and JavaScript typed arrays.

    Good luck!

    0 0
  • 03/11/16--01:09: New Post: Date marshalling
  • Hi, thanks for the release, I've tested it and it's working fine!

    I just have a issue with the equality comparison (which use a reference comparison when both operands are of the same type),
    Would that be possible to make equality operators work with .NET structs types?
    I guess there's probably a technical reason preventing that, just asking to be sure.

    Thanks.

    0 0

    What I´m doing is passing the array as parameter to a c# method that is awaiting for a byte array. Do you think that if I use Uint8Array that can be mapped into a byte array on the c# side?.

    Thanks.

    0 0
  • 03/11/16--13:10: New Post: Date marshalling
  • Hello!

    Unfortunately valueOf isn't used to prepare values for equality comparison, nor is it possible for the host to overload JavaScript operators. And as you probably know, comparing structs by reference doesn't even work for managed code :)

    ClearScript does have a scheme in place that makes JavaScript equality comparison work for .NET enum values. It's somewhat memory intensive, but that's offset by the tiny value range of most enums. In theory the same technique could work for other value types, but currently it's enabled only for enums due to memory consumption concerns.

    Thanks!

    0 0

    Hi nicoriff,

    There's no automatic mapping; you'd have to convert the Uint8Array array to System.Byte[] explicitly. Recent ClearScript versions provide a fast API for that.

    As for which array type to use, that depends on which side is doing most of the array access. If the answer is "both", and if we're talking about a large array, then explicit conversion might be the best option.

    Cheers!

    0 0

    Context: Azure, C#, ClearScript.V8.5.4.5

    I have a number of C# programs running under the scheduler in an Azure VM. All but two are currently working due to an error which identifies itself by a last run result of 0xE0434352.

    In Event Viewer -> Windows Logs -> Application there are a number of errors listed, all of which say mostly the same as the following

    ```
    Application: NormanEmailHandler.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ComponentModel.Win32Exception at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D) at MS.Win32.HwndWrapper..ctor(Int32, Int32, Int32, Int32, Int32, Int32, Int32, System.String, IntPtr, MS.Win32.HwndWrapperHook[]) at System.Windows.Threading.Dispatcher..ctor() at System.Windows.Threading.Dispatcher.get_CurrentDispatcher() at Microsoft.ClearScript.Windows.WindowsScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at NormanEmailHandler.Program..cctor() Exception Info: System.TypeInitializationException at NormanEmailHandler.Program.Main(System.String[])
    ```

    I have looked at and tried the code samples at [AppDomain.UnhandledException Event](https://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.71).aspx) however the EXE fails before that code gets executed, even when it's the first thing encountered in the Main().

    It does occur to me as I write this that instantiating the object before Main() kicks in might have something to do with the exception handler not firing. What's be nice, though would be to know why I'm having the problem at all.

    ```
    namespace NormanEmailHandler
    {
    class Program
    {
    static JScriptEngine JSengine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging | WindowsScriptEngineFlags.EnableJITDebugging);

    ```


    0 0

    Context: Azure, C#, ClearScript.V8.5.4.5

    I have a number of C# programs running under the scheduler in an Azure VM. All but two are currently working due to an error which identifies itself by a last run result of 0xE0434352.

    In Event Viewer -> Windows Logs -> Application there are a number of errors listed, all of which say mostly the same as the following

    ```
    Application: NormanEmailHandler.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ComponentModel.Win32Exception at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D) at MS.Win32.HwndWrapper..ctor(Int32, Int32, Int32, Int32, Int32, Int32, Int32, System.String, IntPtr, MS.Win32.HwndWrapperHook[]) at System.Windows.Threading.Dispatcher..ctor() at System.Windows.Threading.Dispatcher.get_CurrentDispatcher() at Microsoft.ClearScript.Windows.WindowsScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at NormanEmailHandler.Program..cctor() Exception Info: System.TypeInitializationException at NormanEmailHandler.Program.Main(System.String[])
    ```

    I have looked at and tried the code samples at [AppDomain.UnhandledException Event](https://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.71).aspx) however the EXE fails before that code gets executed, even when it's the first thing encountered in the Main().

    It does occur to me as I write this that instantiating the object before Main() kicks in might have something to do with the exception handler not firing. What's be nice, though would be to know why I'm having the problem at all.

    ```
    namespace NormanEmailHandler
    {
    class Program
    {
    static JScriptEngine JSengine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging | WindowsScriptEngineFlags.EnableJITDebugging);

    ```

    Comments: Hello, Given your stack trace, the problem might be that your scheduled task has no access to an interactive desktop, which is a requirement for Windows script engines such as JScript. Consider instantiating the script engine from a context that would allow you to catch the exception and examine its properties. Specifically, [`Win32Exception.NativeErrorCode`](https://msdn.microsoft.com/en-us/library/system.componentmodel.win32exception.nativeerrorcode(v=vs.110).aspx) could provide a clue. Also, consider switching to `V8ScriptEngine`, a more modern JavaScript engine that has no interactive desktop requirement. Good luck!

    0 0

    Hi,

    We currently use ClearScript v5.4.2 and wanted to upgrade to v5.4.4, but some of our tests started failing. This is because the method "toString()" no longer binds to the method on the managed instance of the HostObject - this means that it always returns "[object HostObject]".

    I also tried using extension methods and interface methods, but all of them return the same string: "[object HostObject]". The problem is that we can't upgrade to ClearScript v5.4.4 because of this issue. If it turns out to be a v8 issue that can't be fixed in ClearScript, do you know what version of v8 made it stop working?

    I attached an additional test fixture that you can just add to the ClearScriptTest project so you can see experience the problem.

    Thank you.

    0 0

    Hello! First of all thank you for this amazing library and your great effort in maintaining it!

    I am building a runtime on top of ClearScript that supports node-like requiring of scripts and dll's. I also implemented a REPL feature to explore my objects in console and print them like node does. I do so by enumerating Object.keys(obj).

    The issue I am facing is confusing - ```Object.keys()``` is returning names of extension methods even if the object is not suitable for those methods (different type), but only if the assembly containing those methods is exposed in a specific way to script. The type containing the extension methods is not required to be exposed, only the assembly suffices.

    How I managed to narrow down the reproduction:

    bot.js:
    ```js
    // The assembly I want to import
    var telegram = require('./Telegram.Bot.dll');
    // require loads the file dynamically and returns a wrapper for its System.Reflection.Assembly
    // calling root() on that wrapper returns a new HostTypeCollection(assembly) in C#
    var root = telegram.root();

    // use the library as it's intended (note: the bug occurs even without this line)
    var api = new root.Telegram.Bot.Api(......);

    // The next line returns a regular CLR object module
    var core = require('core');

    var keys = Object.keys(core); // keys now contains ToUnixTime and some other irrelevant extensions!
    // From the source code of the library: public static long ToUnixTime(this DateTime self) { ... }
    // My object is not a DateTime, nor did I import root.Telegram.Bot.Helpers.Extensions
    // class where it resides

    // Calling sleep tells the runtime to start a REPL
    //after the script file finishes running instead of terminating
    core.sleep();
    // Exporting object to global namespace
    global.core = core;
    ```

    After running this file with my executable, if I type ```core``` in my REPL, It still prints out those keys, and evaluating ```core.ToUnixTime``` as a command returns ```[HostMethod:ToUnixTime]```, trying to invoke ```core.ToUnixTime()``` throws ```... does not contain a definition for 'ToUnixTime'```. This issue pollutes my objects and defeats the purpose of having an inspector.

    This bug does not occur (at first) under these conditions:
    ```js
    global.telegram = require('./Telegram.Bot.dll');
    // I am not exposing root() here
    global.core = require('core');
    global.core.sleep();
    ```

    After this file finishes running, typing ```root = telegram.root()``` in REPL exposes the assembly but does not introduce those buggy extension methods. More so, calling ```ext = root.Telegram.Bot.Helpers.Extensions``` does not cause any trouble. However, objects exposed afterwards: ```console = require('console')``` get polluted.

    Notes:
    -I am using the latest version of ClearScript from NuGet (v5.4.4)
    -Executing files runs them within a ```function (exports, require, module, __filename, __dirname) { code }``` wrapper.
    -This means that the first case is entirely executed within a engine.Execute(...) call.
    -The bug occurs in the first case even if core is exposed before the library.
    -The REPL loop starts after executions are finished, so in the second case it is a different execution - an engine.Evaluate(...) more exactly.
    -Runtime source code https://github.com/EdonGashi/ShipScript
    -Library source code https://github.com/MrRoundRobin/telegram.bot

    Thanks!

    0 0

    Context: Azure, C#, ClearScript.V8.5.4.5

    I have a number of C# programs running under the scheduler in an Azure VM. All but two are currently working due to an error which identifies itself by a last run result of 0xE0434352.

    In Event Viewer -> Windows Logs -> Application there are a number of errors listed, all of which say mostly the same as the following

    ```
    Application: NormanEmailHandler.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ComponentModel.Win32Exception at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D) at MS.Win32.HwndWrapper..ctor(Int32, Int32, Int32, Int32, Int32, Int32, Int32, System.String, IntPtr, MS.Win32.HwndWrapperHook[]) at System.Windows.Threading.Dispatcher..ctor() at System.Windows.Threading.Dispatcher.get_CurrentDispatcher() at Microsoft.ClearScript.Windows.WindowsScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at NormanEmailHandler.Program..cctor() Exception Info: System.TypeInitializationException at NormanEmailHandler.Program.Main(System.String[])
    ```

    I have looked at and tried the code samples at [AppDomain.UnhandledException Event](https://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.71).aspx) however the EXE fails before that code gets executed, even when it's the first thing encountered in the Main().

    It does occur to me as I write this that instantiating the object before Main() kicks in might have something to do with the exception handler not firing. What's be nice, though would be to know why I'm having the problem at all.

    ```
    namespace NormanEmailHandler
    {
    class Program
    {
    static JScriptEngine JSengine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging | WindowsScriptEngineFlags.EnableJITDebugging);

    ```

    Comments: Okay, I'll give it a shot. The weird thing is that it was all working fine until halfway through today when it stopped working. I haven't figured out why. I've trapping the exception in a try/catch but it doesn't get caught. V8ScriptEngine is possible, but then how do I debug in Visual Studio? Think I need more than luck. Anyone want to pray?

    0 0

    Context: Azure, C#, ClearScript.V8.5.4.5

    I have a number of C# programs running under the scheduler in an Azure VM. All but two are currently working due to an error which identifies itself by a last run result of 0xE0434352.

    In Event Viewer -> Windows Logs -> Application there are a number of errors listed, all of which say mostly the same as the following

    ```
    Application: NormanEmailHandler.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ComponentModel.Win32Exception at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D) at MS.Win32.HwndWrapper..ctor(Int32, Int32, Int32, Int32, Int32, Int32, Int32, System.String, IntPtr, MS.Win32.HwndWrapperHook[]) at System.Windows.Threading.Dispatcher..ctor() at System.Windows.Threading.Dispatcher.get_CurrentDispatcher() at Microsoft.ClearScript.Windows.WindowsScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at NormanEmailHandler.Program..cctor() Exception Info: System.TypeInitializationException at NormanEmailHandler.Program.Main(System.String[])
    ```

    I have looked at and tried the code samples at [AppDomain.UnhandledException Event](https://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.71).aspx) however the EXE fails before that code gets executed, even when it's the first thing encountered in the Main().

    It does occur to me as I write this that instantiating the object before Main() kicks in might have something to do with the exception handler not firing. What's be nice, though would be to know why I'm having the problem at all.

    ```
    namespace NormanEmailHandler
    {
    class Program
    {
    static JScriptEngine JSengine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging | WindowsScriptEngineFlags.EnableJITDebugging);

    ```

    Comments: >The weird thing is that it was all working fine until halfway through today when it stopped working. I haven't figured out why. ​ Is it possible that your task is configured to run under an account that has been logged off or closed its interactive session? Also, have a look [here](https://social.msdn.microsoft.com/Forums/vstudio/en-US/6057e441-a664-4db3-9593-c11dc57da051/why-does-dispatchercurrentdispatcher-throw-an-exception?forum=wpf) for a discussion of an exception that's very similar to yours. Is your task heavily multi-threaded, or is it possible that your VM is running many instances of it? In any case, the native error code is definitely worth catching if possible.

    0 0

    Context: Azure, C#, ClearScript.V8.5.4.5

    I have a number of C# programs running under the scheduler in an Azure VM. All but two are currently working due to an error which identifies itself by a last run result of 0xE0434352.

    In Event Viewer -> Windows Logs -> Application there are a number of errors listed, all of which say mostly the same as the following

    ```
    Application: NormanEmailHandler.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ComponentModel.Win32Exception at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D) at MS.Win32.HwndWrapper..ctor(Int32, Int32, Int32, Int32, Int32, Int32, Int32, System.String, IntPtr, MS.Win32.HwndWrapperHook[]) at System.Windows.Threading.Dispatcher..ctor() at System.Windows.Threading.Dispatcher.get_CurrentDispatcher() at Microsoft.ClearScript.Windows.WindowsScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at NormanEmailHandler.Program..cctor() Exception Info: System.TypeInitializationException at NormanEmailHandler.Program.Main(System.String[])
    ```

    I have looked at and tried the code samples at [AppDomain.UnhandledException Event](https://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.71).aspx) however the EXE fails before that code gets executed, even when it's the first thing encountered in the Main().

    It does occur to me as I write this that instantiating the object before Main() kicks in might have something to do with the exception handler not firing. What's be nice, though would be to know why I'm having the problem at all.

    ```
    namespace NormanEmailHandler
    {
    class Program
    {
    static JScriptEngine JSengine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging | WindowsScriptEngineFlags.EnableJITDebugging);

    ```

    Comments: > the problem might be that your scheduled task has no access to an interactive desktop, which is a requirement for Windows script engines such as JScript. In the original [MSScriptControl](https://msdn.microsoft.com/en-us/library/aa227400(v=vs.60).aspx) a property could be set to false to cause scripts not to require a UI (well, that's how I'm reading it at the moment), viz > AllowUI When set to True, means that the script program can display user interface (UI) elements such as a MsgBox Setting it to False is what I'm assuming would remove the UI requirement. I had hoped that perhaps there was a similar property available in the ClearScript engine. There isn't so I'd better try something else. AND find out what the native error code is.

    0 0

    Hi,

    I need to call a function in my Javascript which takes a Javascript object as parameter. The catch is that the property names of the object are something like "a.b" or "foo.bar" and they are dynamic, so I cannot create a static object to call with.

    Is there any way to call the function with a Dictionary<string, object> and have it converted to a Javascript object automatically?

    So far I've done a workaround:
    1. Create the Dictionary<string, object>, add values
    2. Convert it to JSON
    3. Call the Javascript function
    4. In the function use JSON.parse to turn it into a Javascript object
    It works, but it's clunky.

    Thanks a lot!

    0 0

    Context: Azure, C#, ClearScript.V8.5.4.5

    I have a number of C# programs running under the scheduler in an Azure VM. All but two are currently working due to an error which identifies itself by a last run result of 0xE0434352.

    In Event Viewer -> Windows Logs -> Application there are a number of errors listed, all of which say mostly the same as the following

    ```
    Application: NormanEmailHandler.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ComponentModel.Win32Exception at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D) at MS.Win32.HwndWrapper..ctor(Int32, Int32, Int32, Int32, Int32, Int32, Int32, System.String, IntPtr, MS.Win32.HwndWrapperHook[]) at System.Windows.Threading.Dispatcher..ctor() at System.Windows.Threading.Dispatcher.get_CurrentDispatcher() at Microsoft.ClearScript.Windows.WindowsScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(System.String, System.String, Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at Microsoft.ClearScript.Windows.JScriptEngine..ctor(Microsoft.ClearScript.Windows.WindowsScriptEngineFlags) at NormanEmailHandler.Program..cctor() Exception Info: System.TypeInitializationException at NormanEmailHandler.Program.Main(System.String[])
    ```

    I have looked at and tried the code samples at [AppDomain.UnhandledException Event](https://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.71).aspx) however the EXE fails before that code gets executed, even when it's the first thing encountered in the Main().

    It does occur to me as I write this that instantiating the object before Main() kicks in might have something to do with the exception handler not firing. What's be nice, though would be to know why I'm having the problem at all.

    ```
    namespace NormanEmailHandler
    {
    class Program
    {
    static JScriptEngine JSengine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging | WindowsScriptEngineFlags.EnableJITDebugging);

    ```

    Comments: And now, to make matters even more anomalous, the VM's been rebooted and everything's back to normal with the JScript instances running quite happily under the Scheduler. Weird, weird, weird.

older | 1 | .... | 94 | 95 | (Page 96) | 97 | 98 | .... | 115 | newer