SlackAPI icon indicating copy to clipboard operation
SlackAPI copied to clipboard

File not found exception

Open gboysen opened this issue 8 years ago • 7 comments

I got some help by friend to set up a simple slackbot using the slackAPI and is was quite easy. It runs on my friend PC, my Office and old home PC but not on my Laptop. I am getting following error. image

gboysen avatar Apr 26 '17 03:04 gboysen

Looks like you forgot to copy the SlackAPI.dll with the .exe, you need that.

Inumedia avatar Apr 26 '17 03:04 Inumedia

Thank you Andy, I am fairly new and would need more help. I will have look later tonight after work. I am in the CDT. If compile it and run the...exe on my office PC I get the same error. If I compile on my office PC it runs and if i run that ...exe on my laptop it fails. So I need to find an slackapi.dll file and copy it to where? Does the ..dll file should be in the same folder as the ...exe file? . BTW I use VS 2017 on all machines and got slackapi via Nuget .

Sent from my iPhone

On Apr 25, 2017, at 10:59 PM, Andy [email protected] wrote:

Looks like you forgot to copy the SlackAPI.dll with the .exe, you need that.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

gboysen avatar Apr 26 '17 12:04 gboysen

In the bin\Debug or bin\Release folder there should be multiple files including the SlackAPI dll. What project type was used?

andymac4182 avatar Apr 26 '17 13:04 andymac4182

Well I used Console APP (.NET framework) and slackspi.dll file are in the folder. The main difference between my work PC and laptop is that the laptop used VS2017RC and does not make a release folder. I copied the whole folder form my work PC to laptop and it still does not run correctly. It seem as my cmd is different.

gboysen avatar Apr 27 '17 02:04 gboysen

after inspection the laptop has Command Prompt form 2009 while the other PC has one from 2016

gboysen avatar Apr 27 '17 02:04 gboysen

`using SlackAPI; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks;

namespace slackbot00 { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!!!"); Console.WriteLine("Connecting to Salck ....."); try {

            ManualResetEventSlim clientReady = new ManualResetEventSlim(false);
            // user @snowridge token 
            //SlackSocketClient client = new SlackSocketClient("xoxp-34787471025-34793444786-138593930854-cd412e1c23a9a997824bde02eea3f1e2");

            // BOT USER TOKEN                
            SlackSocketClient client = new SlackSocketClient("xoxb-68681642323-3xYt1Ifb6xNif0DfpvQWmWJz");
            client.Connect((connected) =>
            {
                // This is called once the client has emitted the RTM start command
                clientReady.Set();
            }, () =>
            {
                // This is called once the RTM client has connected to the end point
            });
            client.OnMessageReceived += (message) =>
            {
                // Handle each message as you receive them

                Console.WriteLine(message.text);

                var lastmessage = message.text;
                Console.WriteLine("this is the variable");
                Console.WriteLine(lastmessage);

                client.GetChannelList((clr) => { Console.WriteLine("got channels"); });
                var c = client.Channels.Find(x => x.name.Equals("bot_heaven"));

                if (lastmessage == "Hello")
                {
                    Console.WriteLine("Hello to you as well");
                }

                if (lastmessage.Contains ("ungry"))
                {
                    // Console.WriteLine("Do you like pizza?");
                    List<string> Foodmaincourse = new List<string> {"Pizza", "Pasta", "BBQ","Burgers","Steak", "Hot dogs" };
                    //var x == Random.next(0, 5);
                    Console.WriteLine(Foodmaincourse[0]);
                    Console.WriteLine(Foodmaincourse[1]);
                    Console.WriteLine(Foodmaincourse[2]);
                    Console.WriteLine(Foodmaincourse[3]);
                    Console.WriteLine(Foodmaincourse[4]);
                    Console.WriteLine(Foodmaincourse[5]);
                    
                    client.SendMessage((mr) => Console.WriteLine("sent message to bot heaven!"), c.id, "Hungry !!!- Do you like pizza?");
                }

              

                
                
                client.SendMessage((mr) => Console.WriteLine("sent message to bot heaven!"), c.id, "Hello from C# Laptop ");
                                   
            };
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
        finally
        {
            Console.ReadLine();
        }
    }
}

} `

gboysen avatar Apr 27 '17 02:04 gboysen

@gboysen Could you check SlackAPI.dll and Newtonsoft.Json.dll are present in the bin folder? Both files are required

gpailler avatar Nov 02 '18 02:11 gpailler