C
C#5mo ago
DevLop games

✅ 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
Salman5mo ago
Because the Game class doesn't exist in that Rythom Namespace, it might be in another namespace
SleepWellPupper
SleepWellPupper5mo ago
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
Salman5mo ago
Yeah possible
SleepWellPupper
SleepWellPupper5mo ago
I'm assuming your Gameclass is defined in namespace Rythm.Flow as well
Salman
Salman5mo ago
Maybe just try using Rythom_Flow;
SleepWellPupper
SleepWellPupper5mo ago
you're already in that namespace
Salman
Salman5mo ago
Yeah but just in case
SleepWellPupper
SleepWellPupper5mo ago
@DevLop games are you coming from a python background perchance?
DevLop games
DevLop gamesOP5mo ago
Why? I mean yea but why? I stil get the same error
Salman
Salman5mo ago
Can you show your Game class Or file
DevLop games
DevLop gamesOP5mo 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
Salman5mo 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 gamesOP5mo ago
Same error
SleepWellPupper
SleepWellPupper5mo ago
Can you share the line the error is being reported on? Screenshot of the error would be helpful
DevLop games
DevLop gamesOP5mo ago
This is the error using (Game game = new Game())
SleepWellPupper
SleepWellPupper5mo ago
Are you using Visual Studio?
DevLop games
DevLop gamesOP5mo ago
No vs code
SleepWellPupper
SleepWellPupper5mo ago
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 gamesOP5mo ago
It still gave errors
SleepWellPupper
SleepWellPupper5mo ago
The same error? Are there multiple errors now?
DevLop games
DevLop gamesOP5mo ago
There's only one
DevLop games
DevLop gamesOP5mo ago
No description
SleepWellPupper
SleepWellPupper5mo ago
Alright, and adding using OpenTKWindow; to the usings doesn't help?
DevLop games
DevLop gamesOP5mo ago
no
SleepWellPupper
SleepWellPupper5mo ago
ctrl+. on the Game game = Game() doesn't show help?
DevLop games
DevLop gamesOP5mo ago
Nothing related to using a namespace from a different file
SleepWellPupper
SleepWellPupper5mo ago
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 gamesOP5mo ago
This whole thing is confusing
SleepWellPupper
SleepWellPupper5mo ago
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
Salman5mo 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
SleepWellPupper5mo ago
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 gamesOP5mo ago
Same error
Salman
Salman5mo ago
what error maybe clean your project or restart VS
DevLop games
DevLop gamesOP5mo ago
wdym clean
Salman
Salman5mo ago
aight forget that for now, trying restarting the VS and see
DevLop games
DevLop gamesOP5mo ago
Now it see my namespace
Salman
Salman5mo ago
good
DevLop games
DevLop gamesOP5mo ago
Now question Why did it detect my namespace when i restarted vs code?
Salman
Salman5mo ago
it's buggy sometimes
kurumi
kurumi5mo ago
intelisence bug
Salman
Salman5mo ago
or cache problem or whatever
kurumi
kurumi5mo ago
sometimes I save my time by doing compilation manually with terminal
DevLop games
DevLop gamesOP5mo ago
Wait so i had it right? I just needed a restart... That fixes it?
kurumi
kurumi5mo ago
no, that's ignore it
DevLop games
DevLop gamesOP5mo ago
k
kurumi
kurumi5mo ago
$close
MODiX
MODiX5mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server