Inject .Net Code Error

@kevin.moore

Hello Kevin,

I have never used this activity before. This activity “Injects .NET code into the main UI thread of the target application. Intended for usage with .NET UI applications that do not expose traditional automation technologies or cannot be correctly targeted by traditional means”, as the documentation says. In my opinion really only for special use cases to apply.

I changed your code a little bit:

public class Class1
    {
        public static object testMethod()
        {
            return "Hello World from the DLL!";
        }
    }

It delivers now an object back, because I assume a console output will not really work in this context. As target I use a tiny dotNET Windows Forms application and it works as expected.

image

image

I recommend you to use the Invoke Code Activity instead of Inject dotNET DLL code into a running application. Running DLL code is much easier with Invoke Code activity. Unless you want to automate an UI that can’t be automated on another way.

Best regards
Stefan

3 Likes