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