Inumedia / SlackAPI

.NET Implementation of the Slack team communication platform API.
MIT License
451 stars 243 forks source link

File not found exception #108

Open gboysen opened 7 years ago

gboysen commented 7 years ago

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

Inumedia commented 7 years ago

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

gboysen commented 7 years ago

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 notifications@github.com 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.

andymac4182 commented 7 years ago

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

gboysen commented 7 years ago

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 commented 7 years ago

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

gboysen commented 7 years ago

`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();
        }
    }
}

} `

gpailler commented 5 years ago

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