After running my project few times I'm getting error: Could not resolve COM reference "f8937e53-d444-4e71-9275-35b64210cc3b" what's that?

3

This is the full error:

Error   1   Could not resolve COM reference "f8937e53-d444-4e71-9275-35b64210cc3b" version 1.0. The specified image file did not contain a resource section. (Exception from HRESULT: 0x80070714)   UsingAutoIt

Never had it before google didn't find anything with this reference long number and letters.

This is my form1 complete code not that long. Maybe the DllImport make the problem ? But it didn't before. Strange error.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using AutoItX3Lib;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace UsingAutoIt
{
    public partial class Form1 : Form
    {
        [DllImport("USER32.DLL")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);


        static AutoItX3Lib.AutoItX3Class au3;
        static Thread thread;
        static bool threadshouldexecute = true;
        static int i = 0;
        string processName = "GameCapture";
        string existingProcessName = "Game Capture HD";
        string processFileName = @"C:\Program Files (x86)\Elgato\GameCapture\GameCapture.exe";
        IntPtr windowHandle;

        public Form1()
        {
            InitializeComponent();


            au3 = new AutoItX3Lib.AutoItX3Class();
            au3.AutoItSetOption("WinTitleMatchMode", 4);

            if (au3.WinExists(existingProcessName, "") == 0) // Window not found
            {
                int processId = au3.Run(processFileName, "", au3.SW_SHOW);
                BringToFront(processId);
                Thread.Sleep(10000);
                au3.MouseClick("LEFT", 358, 913, 1, -1);

            }
            else
            {
                Process[] processes = Process.GetProcessesByName(processName);
                BringToFront(processes[0].Id);
                au3.MouseClick("LEFT", 358, 913, 1, -1);
            }
        }

        public static void BringToFront(int processId)
        {
            Process process = Process.GetProcessById(processId);
            IntPtr handle = process.MainWindowHandle;

            if (handle == IntPtr.Zero)
                return;

            SetForegroundWindow(handle);
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
            t1.Interval = 50;
            t1.Tick += new EventHandler(timer1_Tick);
            //t1.Enabled = true;
            t1.Enabled = false;
        }

        public static Point GetMousePosition()
        {
            var position = System.Windows.Forms.Cursor.Position;
            return new Point(position.X, position.Y);
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text = string.Format("X={0}, Y={1}", GetMousePosition().X, GetMousePosition().Y);
        }
    }
}
c#
.net
winforms
autoit-c#-wrapper
asked on Stack Overflow Jul 5, 2015 by Manuel Spechia • edited Mar 6, 2020 by user4157124

1 Answer

2

But to do that I had first to register using regsrv32 only after register it I could add as reference the dll file.

This is normal, Visual Studio stores the guid of the type library in the project file. A type library is a description of the types exported by the COM component. Very similar to metadata in a .NET assembly. Finding the library back from the "f8937e53-d444-4e71-9275-35b64210cc3b" guid in the project file requires Visual Studio to look in the registry, HKCR\TypeLib key. It is not going to be there until after the COM component is registered. Yes, Regsvr32.exe, in general it is better to use the component's installer.

I had to change the property Embed Interop Types to false

That is because you used AutoItX3Lib.AutoItX3Class in your source code. This is a synthetic class that is generated from the type library, it makes COM components that implement multiple interfaces a bit easier to use. Such a synthetic class however cannot be embedded, that's why you had to set the property to false. The simple workaround for that is to omit "Class" from the type name so you only use the interface. Fix:

    static AutoItX3Lib.AutoItX3 au3;
    ....
    au3 = new AutoItX3Lib.AutoItX3();
answered on Stack Overflow Jul 5, 2015 by Hans Passant

User contributions licensed under CC BY-SA 3.0