V8ScriptEngine - System.IO.FileNotFoundException occurred in mscorlib.dll

Aug 1, 2014 at 1:17 PM
I have an application that is using VBS, JScript and V8 allowing me to switch easily between languages. All is working well but I notice that the 1st time I load the V8 Script Engine (and only this one) I get the following error message :
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

My code is simply doing this
if (v8engine == null) v8engine = new V8ScriptEngine(V8ScriptEngineFlags.EnableDebugging);

It does not seem to matter whether I have debugging Enabled or not.
Whilst this is only a minor irritation it begs the question what is causing it and can I get rid of it.

These are the files I have in my Exe folder (other than my App specific ones)
21/06/2014 00:24 260,608 ClearScript.dll
21/06/2014 00:24 615,936 ClearScript.pdb
21/06/2014 00:24 192,061 ClearScript.xml
21/06/2014 00:25 389,120 ClearScriptV8-32.dll
21/06/2014 00:25 6,024,192 ClearScriptV8-32.pdb
21/06/2014 00:28 3,361,280 v8-ia32.dll
21/06/2014 00:28 4,140,032 v8-x64.dll
Coordinator
Aug 1, 2014 at 2:55 PM
Hi egooner,

This exception is expected during the initialization of ClearScript's V8 support. It should be handled internally.

The long story: ClearScript allows hosts to override its V8 assembly loading procedure via assembly resolution. If the host doesn't provide an assembly resolution handler, the runtime generates this exception; ClearScript handles it and continues with its normal loading procedure.

If you're building ClearScript, you can eliminate the exception (along with the assembly resolution feature) by removing or commenting out these lines in ClearScript\V8\V8Proxy.cs:
try
{
    return Assembly.Load("ClearScriptV8");
}
catch (FileNotFoundException)
{
}
Good luck!