Invalid token 'while' in class, struct, or interface member declaration in very simple code
Solution 1
Based on the error, it sounds like the compiler thinks this code is typed directly in the body of a class/struct/interface declaration. Statements while/if/for/etc ... must appear with in a method.
Try moving this code into a method to fix the problem. If it's in a method, you likely have a mismatched brace problem.
Solution 2
There's nothing wrong with the while, it's something above it that's the problem. Check for mismatched braces and semicolons in a comment or something like that.
Solution 3
C# is not allowed to write code directly into the classes; it is allowed to write only data members and function members directly into the classes.
Arjun Raja
Updated on July 09, 2022Comments
-
Arjun Raja almost 2 years
The bot that has been developed runs in the emulator locally without any problem.
But when we hosted it in Azure. We're not getting any reply from bot.
I tried testing the Bot Connection in dev.botframework.com, I get an "Endpoint authorization succeeded message".
can anyone let me know what could be the issue.?
-
Admin over 7 yearsWhat's the channel that you're using? Telegram, fb, skype?
-
Arjun Raja over 7 yearsSkype and Webchat
-
Arjun Raja over 7 yearsThere is a good chance that I did something wrong with the connection string. <add name="DBCS" connectionString="Data Source=xxx.database.windows.net,1433;Initial Catalog=<dbname>;Integrated Security=False; TrustServerCertificate=False;User ID=yyy@xxx;Password=####;Connection Timeout=30" />
-
andrea-lam-MSFT over 7 yearsDid you include System.Data.SqlClient as a provider?
-
Arjun Raja over 7 yearsI tried including that also. It didn't work.
-
-
Arjun Raja over 7 yearsThanks for your reply.. My endpoint is already like what you have mentioned. From dev.bot framework I get a success message "Endpoint Authorization Succeeded." But, Whenever I send a message. It gets added as internal server error in issues of the channel.
-
Jim Lewallen over 7 yearsAre you able to debug your bot online to catch exceptions? It's possible Bot Framework is sending you an ActivityType other than "message" and your bot isn't handling it. For example, you may be getting "conversationUpdated" Activity with a null message body.
-
Arjun Raja over 7 yearsThe issue is fixed now. The bot.connector I used had a bug and it was fixed in 3.0.1. So I updated them.