Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Using ClearScript. WebApplication problem

0
0
Hi willeyams,

you can use the AssemblyResolve event to point your application to the correct binaries. I've deployed successfully my ASP.NET application to Azure with this technique. First, you register the event handler in the Application_Start method of your website like this:
        void Application_Start(object sender, EventArgs e)
        {
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
        }
This is the way I'm handling the loading:
        Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            if (args.Name.Contains("ClearScript"))
            {
                var rootPath = HostingEnvironment.MapPath("/Dependencies");

                try
                {
                    _log.Info("Looking for ClearScript in " + Path.Combine(rootPath, "ClearScriptV8-64.dll"));
                    return Assembly.LoadFile(Path.Combine(rootPath, "ClearScriptV8-64.dll"));
                }
                catch (Exception e)
                {
                    _log.Error("Cannot load ClearScript64", e);
                    return Assembly.LoadFile(Path.Combine(rootPath, "ClearScriptV8-32.dll"));
                }
            }

            return null;
        }
Clearly, my /Dependencies directory contains ClearScriptV8-xx.dll as well as v8-xxx.dll (which is probably needed only if you are using V8).

Let me know if this helps! Also, note that the assembly resolve event is probably not handled by the NuGet version (which is not officially supported by the developers) - you'll have to get a version from Codeplex.
Best regards,
Andrea

edit: since this is my first post, I'd like to thank the developers of ClearScript for providing such an amazing package. Keep up the good work :-)

Viewing all articles
Browse latest Browse all 2297