Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Hildreth
16,170 PointsIs there a bug within the C# compiler/console in workspaces?
So I've had this issue before, and I keep having it when I'm in the command prompt of workspaces it seems. I'll go to do the query syntax like birds."X", but I keep getting some type of error each time almost where it'll say "X" doesn't exist in current context. For instance, I'll load up the BirdWatcher.dll in the workspaces prompt and use it. Then I'll add the var birds = BirdRepository.LoadBirds(); to the code. A little after that after running a few code lines and Linq statements, I'll get that error message. Does anyone know why I am getting this message? Is there a bug within the workspaces? I follow the videos along to the "T", but still somehow get these errors. I also seem to notice it after running the Console.Clear(); command to clear the console window. I apologize in advance for the length of this post, but this is getting frustrating. Here's a sample of it below:
LoadAssembly("BirdWatcher.dll");
using BirdWatcher;
var birds = BirdRepository.LoadBirds();
birds
Console.Clear();
Then I'll ALT+TAB out of the workspaces to check the video code again to make sure I'm doing it right. Then I type the following and get another internal compiler error:
csharp> var favoriteBirds = birds.Join(color,
> b => b.(1,11): error CS0584: Internal compiler error: Expression Mono.CSharp.ParameterReference did not set its type after Resolve
(1,11): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
C
As soon as I type the "." in b.Color, I get that error message. Does ALT+TAB mess up the compiler, or is this a bug?
I also just got this bug and didn't ALT+TAB or Console.Clear(); and I still got an error message:
treehouse:~/workspace$ csharp
Mono C# Shell, type "help;" for help
Enter statements below.
csharp> LoadAssembly("BirdWatcher.dll");
csharp> using BirdWatcher;
csharp> var birds = BirdRepository.LoadBirds();
csharp> var favoriteBirds = birds.Join(color,
> b.Color,
> c => c,
> (bird, color) => new { Color = color, Bird = bird });
(1,33): error CS0103: The name `color' does not exist in the current context
(2,2): error CS0103: The name `b' does not exist in the current context
(1,28): error CS0411: The type arguments for method `System.Linq.Enumerable.Join<TOuter,TInner,TKey,TResult>(this System.Collections.Generic.IEnumerable<TOuter>
, System.Collections.Generic.IEnumerable<TInner>, System.Func<TOuter,TKey>, System.Func<TInner,TKey>, System.Func<TOuter,TInner,TResult>)' cannot be inferred fr
om the usage. Try specifying the type arguments explicitly
csharp>
csharp> var favoriteBirds = birds.Join(colors,
> b.Color,
> c => c,
> (bird, color) = new { Color = color, Bird = bird });
(4,5): error CS1026: Unexpected symbol `,', expecting `)'
(4,5): error CS1026: Unexpected symbol `)', expecting `)'
(4,6): error CS1026: Unexpected symbol `)', expecting `)'
(4,50): error CS1525: Unexpected symbol `}', expecting `,' or `;'
csharp> var favoriteBirds = birds.Join(colors,
> b => b.(1,11): error CS0584: Internal compiler error: Expression Mono.CSharp.ParameterReference did not set its type after Resolve
(1,11): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Below is a link to the video I'm following and this happened when I was at 5:42 in the video. https://teamtreehouse.com/library/querying-with-linq/query-operators/joins
2 Answers
James Churchill
Treehouse TeacherDaniel,
Sorry to hear that you're encountering this issue with Workspaces C# REPL and thanks for bringing it to our attention.
I was able to reproduce this error and came up with the following temporary fixes:
1) Don't use any line breaks.
var favoriteBirds = birds.Join(colors, b => b.Color, c => c, (bird, color) => bird);
2) Move the comma to the beginning of the line break.
var favoriteBirds = birds.Join(colors
, b => b.Color
, c => c
, (bird, color) => bird);
We're also working on more of a longterm solution to this bug, so hopefully you won't have to use one of these workarounds for long.
There's also another issue with your above code. Be sure to define the colors
collection of string values before you try to reference it in the Join
statement.
I hope this helps get you past these errors.
Thanks ~James
James Churchill
Treehouse TeacherDaniel,
In the Querying with LINQ "Joins" video at around 0:25, Carling defines a colors
collection of strings.
https://teamtreehouse.com/library/querying-with-linq/query-operators/joins
Thanks ~James
Daniel Hildreth
16,170 PointsOk thank you!
Daniel Hildreth
16,170 PointsDaniel Hildreth
16,170 PointsJames what do you mean by defining the colors collection? I thought that was part of the BirdWatcher.dll file that I load in? I say that because when I followed the video, I don't remember defining the colors collection; just writing out the query statements.