July 4, 2007
03:32 PM

I've been chasing a bug in RikReader ever since people started sending error reports back to me. This particular one is curious because it's dependent on the Operating System's UI Language, so I get the reports back in an assortment of languages.

Todo: I could probably serialise these in English initially, but that's not the problem at the moment.

FileNotFoundException:

  • Невозможно загрузить файл или сборку "...y88nnzzx.dll" или один из зависимых от них компонентов. Не удается найти указанный файл.
  • Não foi possível carregar arquivo ou assembly '...7uwqjtre.dll' ou uma de suas dependências. O sistema não pode encontrar o arquivo especificado.
  • Impossible de charger le fichier ou l'assembly '...qxpulisn.dll' ou une de ses dépendances. Le fichier spécifié est introuvable.
  • Det går inte att läsa in filen eller sammansättningen ...pyq_nlzi.dll eller ett av dess beroenden. Det går inte att hitta filen.
  • 無法載入檔案或組件 '...5gxdnvh4.dll' 或其相依性的其中之一。 系統找不到指定的檔案。
  • Die Datei oder Assembly ...6dokpecz.dll oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
  • ファイルまたはアセンブリ '...gnxsmxbd.dll'、またはその依存関係の 1 つが読み込めませんでした。指定されたファイルが見つかりません。

Which I think means "Unable to load assembly <file.dll> or one of its dependencies. The file cannot be found."

It was caused by this seemingly innocent code in JScriptConverter:

CompilerParameters cp = new CompilerParameters();
cp.GenerateInMemory = true;

CompilerResults results = 
    new Microsoft.JScript.JScriptCodeProvider()
    .CompileAssemblyFromSource(cp, source);

Assembly result = results.CompiledAssembly;

I have the Japanese MUI set up on another account, so I was able to find out that CompileAssemblyFromSource was setting an error status which I didn't check. That error being the even more cryptic:

error JS2999: Microsoft.Vsa.VsaException: ItemNameInUse (0x80133024)

I don't know what that means, nor why it is dependent on MUI. So I gave up searching and just rewrote JScriptConverter to set up the evaluation from C# instead of generating a seperate assembly.

private static VsaEngine engine = VsaEngine.CreateEngine();
private static JSLocalField[] fields = new JSLocalField[]
    { new JSLocalField("values", typeof(object[]).TypeHandle, 0) };

private static object Evaluate(string code, object[] values)
{
    StackFrame.PushStackFrameForMethod(new object(), fields, engine);
    ((StackFrame)engine.ScriptObjectStackTop()).localVars[0] = values;
    object result = Eval.JScriptEvaluate(code, "unsafe", engine);
    engine.PopScriptObject();
    return result;
}

Which turned out simpler than expected. The full implementation of JScriptConverter is here.

© Douglas Stockwell 2007
Creative Commons License Unless otherwise specified all "source code" examples are available for use under the Creative Commons Attribution-Noncommercial 3.0 License. Please contact me if you would like more flexible licensing terms.
Messenger Presence