Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Launching Xna App From Another Project

Xna project program xna

  • Please log in to reply
4 replies to this topic

#1 nunnbt473

nunnbt473

    CC Lurker

  • New Member
  • Pip
  • 8 posts
  • Location:VA
  • Learning:C++, C#

Posted 23 June 2012 - 06:25 AM

I just recently started picking up some coding again and took on an old project of mine. However, I was a bit random about which pieces I was creating and separated the program into a few different projects. Well I recombined them all and my XNA Game app now fails to launch due to the following errors.

Error 4 'NsDrawing.Game1' does not contain a definition for 'Run' and no extension method 'Run' accepting a first argument of type 'NsDrawing.Game1' could be found (are you missing a using directive or an assembly reference?) C:\Shortened\Game\Project3\AccountLogin.cs 42 20 Accounts



A couple of other errors did pop up after I started up the project unexpectedly this time, but that is the main error I have been experiencing.

Contained in the "accounts" project, on an Account Login form which launches with main. I included using NsDraw; at the top of the code.
		private void buttonLogin_Click(object sender, EventArgs e)
		{
			using (Game1 game = new Game1())
			{ game.Run(); }
		}

The following is in the "XnaGraphics" project in Drawing.cs

namespace NsDrawing
{
	/// <summary>
	/// This is the main type for your game
	/// </summary>
	public class Game1 : Microsoft.Xna.Framework.Game
	{
		GraphicsDeviceManager graphics;
		SpriteBatch spriteBatch;*Edited for relevance*

		public Game1()
		{
			graphics = new GraphicsDeviceManager(this);
			Content.RootDirectory = "Content";
			graphics.PreferredBackBufferWidth = 800;
			graphics.PreferredBackBufferHeight = 600;
			graphics.ApplyChanges();
		}

I can't remember the exact placement I initially had the game.Run segment, but it was in the XNAGraphics project I know and ran without problems. Everything is contained within the same solution.
  • 0

#2 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 23 June 2012 - 07:34 AM

Have you referenced the assembly 'microsoft.xna.framework.game.dll' in your project?
  • 0

#3 nunnbt473

nunnbt473

    CC Lurker

  • New Member
  • Pip
  • 8 posts
  • Location:VA
  • Learning:C++, C#

Posted 23 June 2012 - 07:40 AM

In the Accounts project no, in the XNAGraphics project yes. I set the accounts project as dependent upon the XNAgraphics project, i gather from youre saying that the references dont automatically carry between projects?
  • 0

#4 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 23 June 2012 - 07:44 AM

No, references don't carry among projects.

Game1 class does not contain the definition for 'Run' method but in the microsoft.xna.framework.game.dll assembly. So you need to add reference to that dll.
  • 1

#5 nunnbt473

nunnbt473

    CC Lurker

  • New Member
  • Pip
  • 8 posts
  • Location:VA
  • Learning:C++, C#

Posted 23 June 2012 - 07:49 AM

Ah that explains much then. A simple reference fixed it right up. Converted the second project from an application to a library to avoid the lack of main. And I am well on my way once I research the last error, much thanks!
  • 0





Also tagged with one or more of these keywords: Xna, project, program, xna

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download