J'ai essayé d'obtenir la bibliothèque xWinForms 3.0 (une bibliothèque avec des formes de support dans xna) travaillant avec mon projet C# XNA Game mais je continue d'obtenir le même problème. J'ajoute la référence à mon projet, mets l'instruction using, déclare une variable formCollection puis j'essaye de l'initialiser.Odd "Référence d'objet non définie sur une instance d'un objet" impliquant xWinForms
Chaque fois que je lance le projet, je me arrêté sur cette ligne:
formCollection = new FormCollection(this.Window, Services, ref graphics);
Il me donne l'erreur:
System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object."
Source="Microsoft.Xna.Framework" StackTrace: at Microsoft.Xna.Framework.Graphics.VertexShader..ctor(GraphicsDevice graphicsDevice, Byte[] shaderCode) at Microsoft.Xna.Framework.Graphics.SpriteBatch.ConstructPlatformData() at Microsoft.Xna.Framework.Graphics.SpriteBatch..ctor(GraphicsDevice graphicsDevice) at xWinFormsLib.FormCollection..ctor(GameWindow window, IServiceProvider services, GraphicsDeviceManager& graphics) at GameSolution.Game2.LoadContent() in C:\Users\Owner\Documents\School\Year 3\Winter\Soen 390\TeamWTF_3\SourceCode\GameSolution\GameSolution\Game2.cs:line 45 at Microsoft.Xna.Framework.Game.Initialize() at GameSolution.Game2.Initialize() in C:\Users\Owner\Documents\School\Year 3\Winter\Soen 390\TeamWTF_3\SourceCode\GameSolution\GameSolution\Game2.cs:line 37 at Microsoft.Xna.Framework.Game.Run() at GameSolution.Program.Main(String[] args) in C:\Users\Owner\Documents\School\Year 3\Winter\Soen 390\TeamWTF_3\SourceCode\GameSolution\GameSolution\Program.cs:line 14 InnerException:
Dans un projet que j'ai téléchargé qui a utilisé les xWinForms, je mets ce qui suit code et il compilé et n'a couru aucune erreur. mais quand je l'ai mis dans mon projet, j'ai l'erreur. Est-ce que je commets une erreur stupide à propos de l'inclusion de dll ou de quelque chose? Cela fait des heures que je suis là et je n'arrive pas à trouver quoi que ce soit qui puisse causer ça.
using xWinFormsLib;
public class Game2 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
FormCollection formCollection;
public Game2()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
formCollection = new FormCollection(this.Window, Services, ref graphics);
}
protected override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
}
}
Toute aide serait grandement appréciée ._.