✅ Namespace error

The type or namespace name 'Game' does not exist in the namespace 'Rhythm_Flow' (are you missing an assembly reference?)
using System;
using OpenTK.Windowing.GraphicsLibraryFramework;
using Rhythm_Flow.Game;

namespace Rhythm_Flow
{
public class Program
{
static void Main(string[] args)
{
using (Game game = new Game())
{
game.Run();
}
}
}
}
using System;
using OpenTK.Windowing.GraphicsLibraryFramework;
using Rhythm_Flow.Game;

namespace Rhythm_Flow
{
public class Program
{
static void Main(string[] args)
{
using (Game game = new Game())
{
game.Run();
}
}
}
}
Anyone know why i am getting this error?
47 Replies
Salman
Salman2w ago
Because the Game class doesn't exist in that Rythom Namespace, it might be in another namespace
SleepWellPupper
More likely it does exist in the Rythm_Flow namespace but your using statement is incorrect Try removing the using Rythm_Flow.Game; line
Salman
Salman2w ago
Yeah possible
SleepWellPupper
I'm assuming your Gameclass is defined in namespace Rythm.Flow as well
Salman
Salman2w ago
Maybe just try using Rythom_Flow;
SleepWellPupper
you're already in that namespace
Salman
Salman2w ago
Yeah but just in case
SleepWellPupper
@DevLop games are you coming from a python background perchance?
DevLop games
DevLop games2w ago
Why? I mean yea but why? I stil get the same error
Salman
Salman2w ago
Can you show your Game class Or file
DevLop games
DevLop games2w ago
using OpenTK.Graphics.OpenGL4;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.GraphicsLibraryFramework;

namespace OpenTKWindow
{
public class Game:GameWindow
{
public Game()
:base(GameWindowSettings.Default, NativeWindowSettings.Default)
{

}
}
}
using OpenTK.Graphics.OpenGL4;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.GraphicsLibraryFramework;

namespace OpenTKWindow
{
public class Game:GameWindow
{
public Game()
:base(GameWindowSettings.Default, NativeWindowSettings.Default)
{

}
}
}
Salman
Salman2w ago
So it's clear that it's defined in the OpenTKWindow namespace not in that Rythom Namespace try using OpenTKWindow; or using OpenTKWindow.Game; Former should work fine
DevLop games
DevLop games2w ago
Same error
SleepWellPupper
Can you share the line the error is being reported on? Screenshot of the error would be helpful
DevLop games
DevLop games2w ago
This is the error using (Game game = new Game())
SleepWellPupper
Are you using Visual Studio?
DevLop games
DevLop games2w ago
No vs code
SleepWellPupper
Did you replace using Rhythm_Flow.Game; with using OpenTKWindow;? Does putting the cursor onto the line and using ctrl+. show you any recommendations?
DevLop games
DevLop games2w ago
It still gave errors
SleepWellPupper
The same error? Are there multiple errors now?
DevLop games
DevLop games2w ago
There's only one
DevLop games
DevLop games2w ago
No description
SleepWellPupper
Alright, and adding using OpenTKWindow; to the usings doesn't help?
DevLop games
DevLop games2w ago
no
SleepWellPupper
ctrl+. on the Game game = Game() doesn't show help?
DevLop games
DevLop games2w ago
Nothing related to using a namespace from a different file
SleepWellPupper
files/paths are not relevant to the problem, it's all determined by namespace/class names C# doesn't care about file names or paths like that
DevLop games
DevLop games2w ago
This whole thing is confusing
SleepWellPupper
You can think of namespaces as "virtual" folders to the compiler so if you have two classes defined in the same namespace, they can see each other no problem but if they are in different namespaces, you need to tell the compiler where to find them using using statements
Salman
Salman2w ago
c#
using System;
using Rhythm_Flow.Game;
using OpenTKWindow;

namespace Rhythm_Flow
{
public class Program
{
static void Main(string[] args)
{
using (Game game = new Game())
{
game.Run();
}
}
}
}
c#
using System;
using Rhythm_Flow.Game;
using OpenTKWindow;

namespace Rhythm_Flow
{
public class Program
{
static void Main(string[] args)
{
using (Game game = new Game())
{
game.Run();
}
}
}
}
@DevLop games try this out and see if it works
SleepWellPupper
And since your Game class is in a different namespace than the Program class, you need to add the using statement that tells the compiler where to look for Game when processing your Program class basically, this
DevLop games
DevLop games2w ago
Same error
Salman
Salman2w ago
what error maybe clean your project or restart VS
DevLop games
DevLop games2w ago
wdym clean
Salman
Salman2w ago
aight forget that for now, trying restarting the VS and see
DevLop games
DevLop games2w ago
Now it see my namespace
Salman
Salman2w ago
good
DevLop games
DevLop games2w ago
Now question Why did it detect my namespace when i restarted vs code?
Salman
Salman2w ago
it's buggy sometimes
kurumi
kurumi2w ago
intelisence bug
Salman
Salman2w ago
or cache problem or whatever
kurumi
kurumi2w ago
sometimes I save my time by doing compilation manually with terminal
DevLop games
DevLop games2w ago
Wait so i had it right? I just needed a restart... That fixes it?
kurumi
kurumi2w ago
no, that's ignore it
DevLop games
DevLop games2w ago
k
kurumi
kurumi2w ago
$close
MODiX
MODiX2w ago
If you have no further questions, please use /close to mark the forum thread as answered