<https://stackoverflow.com/posts/72961174/timeline>

I have a Framework 4.8 C# app that uses ClearScript 
<https://www.nuget.org/packages/Microsoft.ClearScript/> to allow JavaScript 
to be used as an extension language. I am able to write plugins as DLLs and 
attach them at runtime with code like:

attach(".\\Plugin_GoogleAds_Metrics.dll"); 
var H = Plugin_GoogleAds_Metrics.GoogleAds_Metrics.Historical; 
var auths = H.AuthoriseFromCFG(cfg,"7212153394");
var acc = H.GetAccountInformation(auths.Item1, 7273576109, true);

The C# code I'm using for the attach is 

JSE.Script.attach = (Func<string, bool>)Attach;

...

private static bool Attach(string dllPath, string name = "")
{
    var status = false;
    var htc = new HostTypeCollection();
    try
    {
        var assem = Assembly.Load(AssemblyName.GetAssemblyName(dllPath));
        htc.AddAssembly(assem);
        if (name.Length == 0)
        {
            name = assem.FullName.Split(',')[0];
        }

        JSE.AddHostObject(name, htc); //FIXME checkout the hosttypes
        Console.Error.WriteLine($"Attached {dllPath} as {name}");
        status = true;
    }
    catch (ReflectionTypeLoadException rtle)
    {
        foreach (var item in rtle.LoaderExceptions)
        {
            Console.Error.WriteLine(item.Message);
            T.Fail(item.Message);
        }

    }
    catch (FileNotFoundException fnfe)
    {
        Console.Error.WriteLine(fnfe.Message);
        T.Fail(fnfe.Message);

    }
    catch (Exception e)
    {
        Console.Error.WriteLine(e.Message);
        T.Fail(e.Message);

    }
    return status;
}

The plugin code FWIW (which isn't much) is at 
<https://github.com/axtens/Plugin_GoogleAds_Metrics>

What's not working in this situation is that when I try to execute the 
plugin's GetAccountInformation method, and execution reaches the 
GoogleAdsServiceClient 
googleAdsService = client.GetService(Services.V11.GoogleAdsService); line, 
an error is thrown complaining about Google.Protobuf, viz
Exception has been thrown by the target of an invocation. at JScript global 
code (Script [23] [temp]:5:0) -> acc = H.GetAccountInformation(auths.Item1, 
7273576109, true) at 
Microsoft.ClearScript.ScriptEngine.ThrowScriptError(IScriptEngineException 
scriptError) at 
Microsoft.ClearScript.Windows.WindowsScriptEngine.ThrowScriptError(Exception 
exception) at 
Microsoft.ClearScript.Windows.WindowsScriptEngine.<>c__DisplayClass57_0`1.<ScriptInvoke>b__0()
 
at Microsoft.ClearScript.ScriptEngine.ScriptInvokeInternal[T](Func`1 func) 
at Microsoft.ClearScript.ScriptEngine.ScriptInvoke[T](Func`1 func) at 
Microsoft.ClearScript.Windows.WindowsScriptEngine.ScriptInvoke[T](Func`1 
func) at 
Microsoft.ClearScript.Windows.WindowsScriptEngine.Execute(UniqueDocumentInfo 
documentInfo, String code, Boolean evaluate) at 
Microsoft.ClearScript.Windows.JScriptEngine.Execute(UniqueDocumentInfo 
documentInfo, String code, Boolean evaluate) at 
Microsoft.ClearScript.ScriptEngine.Evaluate(UniqueDocumentInfo 
documentInfo, String code, Boolean marshalResult) at 
Microsoft.ClearScript.ScriptEngine.Evaluate(DocumentInfo documentInfo, 
String code) at Microsoft.ClearScript.ScriptEngine.Evaluate(String 
documentName, Boolean discard, String code) at 
Microsoft.ClearScript.ScriptEngine.Evaluate(String documentName, String 
code) at Microsoft.ClearScript.ScriptEngine.Evaluate(String code) at 
RulesetRunner.Program.Run(JScriptEngine& jSE, String scriptText, Config 
cfg, Dictionary`2 settings) in 
C:\Users\bugma\Source\Repos\Present\BORR\RulesetRunner\RunManagementPartials.cs:line
 
72 Exception has been thrown by the target of an invocation. Exception has 
been thrown by the target of an invocation. Could not load file or assembly 
'Google.Protobuf, Version=3.15.8.0, Culture=neutral, 
PublicKeyToken=a7d26565bac4d604' or one of its dependencies. The system 
cannot find the file specified. 

So

   1. I am using the latest Google.Ads.GoogleAds library 
   2. AutoGenerateBindingRedirects has been set to true in the csproj file 
   3. Add-BindingRedirect has been executed in the context of the Plugin's 
   project 
   4. The Plugin_GoogleAds_Metrics.dll is in the same folder as the 
   Google.Protobuf.dll
   
   
How is it that "The system cannot find the file specified."? And where do I 
go from here?

-- Bruce

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/ea658cb3-9b59-42ba-9184-35fd7f38434an%40googlegroups.com.

Reply via email to