Skip to content

Implement assembly probing for external script execution (e.g. x86) #414

@oleg-shilo

Description

@oleg-shilo

NOTE assembly caching is also impacted by this issue

OK, I know the answer.
The problem is caused by the assembly probing algorithm for the running script being designed around the execution from the script engine exe, which plays nicely with assembly probing. However, in the case of x86 the host app is a different exe, which has no idea about resolving assemblies required by the script. This is something that I need to revisit and address in the next release.

Let's unblock you first, and then I will proceed with the design update as a separate issue.

This is what you need to do. Since your script host does not have assembly resolving implemented, it's easier to preload the "unresolvable assembly" manually. In this case, it is log4net.dll.

This is how you can achieve it:

//css_ng dotnet
//css_co /platform:x86
//css_nuget log4net
using System.Reflection;

using System;

public static class Program
{
    static void Main()
    {
        Assembly.LoadFrom(Environment.ExpandEnvironmentVariables(
            @"%USERPROFILE%\.nuget\packages\log4net\3.0.4\lib\netstandard2.0\log4net.dll"));
        main();
    }

    static void main()
    {
        // Those lines help me to know if the process is running in 32 or 64 mode
        if (IntPtr.Size == 4)
            Console.WriteLine("Running as 32 bits");
        else if (IntPtr.Size == 8)
            Console.WriteLine("Running as 64 bits");

        Console.WriteLine(typeof(log4net.Config.BasicConfigurator).Assembly.Location);
    }
}

And the next release will have the proper fix for this so you will be able to remove this workaround.

Originally posted by @oleg-shilo in #413

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions