DarthAffe / RGB.NET

The one-stop SDK for RGB-peripherals

Home Page:http://lib.arge.be

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't detect devices when running compiled app through command prompt

rivafarabi opened this issue · comments

Hi there, I want to create a nodejs wrapper which include using small console program which look something like this

static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                throw new ArgumentException("No valid argument.");
            }

            var arguments = new ExecArguments(args);
            var output = new Output();

            try
            {
                RGBSurface surface = RGBSurface.Instance;
                surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
                surface.LoadDevices(CorsairDeviceProvider.Instance);
                surface.LoadDevices(LogitechDeviceProvider.Instance);
                surface.LoadDevices(RazerDeviceProvider.Instance);

                surface.AlignDevices();
                switch (arguments.action.ToLowerInvariant())
                {
                    case "--getdevices":
                        output.data = GetDevices(surface, arguments.deviceType);
                        break;
                    case "--setcolor":
                        output.data = SetColor(surface, arguments.color);
                        break;
                    default:
                        output.error = "No valid argument.";
                        break;
                }
                
            }
            catch (Exception e)
            {
                output.error = e.ToString();
                output.data = null;
            }
            finally
            {
                Console.WriteLine(JsonConvert.SerializeObject(output));
            }
        }

Everything looks good when I run it through cmd (inside the program.exe directory) with something like ./program.exe --getDevices keyboard. The RGBSurface contains all my devices as expected.

But when I run it outside the program.exe directory, something like ./someFolder/moreFolder/program.exe --getDevices keyboard. I can't get my device listed.

Any idea how to solve this? thanks.

Did you copy everything (especially the x86/x64 folder)? This issue sounds like the SDKs aren't correctly loaded in you other location.

yeah. that's the point. I recently tried copy both x86 and x64 folders into the directory where I try to run the .exe from and it worked. But there's a new issue, I have to copy both the folders to my node module whenever I try to access the .exe file.

Well you can use the "PossibleX86NativePaths" and "PossibleX64NativePaths" properties to specify another location, but there's no way for it to work without having the SDK-dlls available.

Thanks man. finally got a lead

string exeDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
CoolerMasterDeviceProvider.PossibleX64NativePaths.Add(exeDir + "\\x64\\CMSDK.dll");
CoolerMasterDeviceProvider.PossibleX86NativePaths.Add(exeDir + "\\x86\\CMSDK.dll");