473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

problem: not valid win32 app

im getting this tutorial:
http://einfall.blogspot.com/2005/02/...to-create.html

and i got some error, i dont know how to fix it.

Can someone help?

i use visual c# express 2008, latest runtime and latest directx
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace VerticesTutorial
{
public class example : Form
{
Device device = null;
VertexBuffer vertexBuffer = null;

static void Main()
{
example form = new example(); //<= this is where i get error message
form.InitializeGraphics();
form.Show();
while (form.Created)
{
//Update our game, and render to screen
form.Render();
Application.DoEvents(); //Let the OS handle what it needs to
}
}

private void Render()
{
if (device == null)
return;
device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);

device.BeginScene();

device.SetStreamSource(0, vertexBuffer, 0);
device.VertexFormat = CustomVertex.TransformedColored.Format;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

device.EndScene();
device.Present();
}

public void InitializeGraphics()
{
try
{
// Now let's setup our D3D stuff
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;

device = new Device(0,
DeviceType.Hardware,
this,
CreateFlags.HardwareVertexProcessing,
presentParams);

device.DeviceReset +=
new System.EventHandler(this.OnResetDevice);
this.OnResetDevice(device, null);
}
catch (DirectXException e)
{
MessageBox.Show(null, "Error intializing graphics: " +
e.Message, "Error");
Close();
}
}

public void OnResetDevice(object sender, EventArgs e)
{
Device dev = (Device)sender;
vertexBuffer
= new VertexBuffer(typeof(CustomVertex.TransformedColore d),
3,
dev,
0,
CustomVertex.TransformedColored.Format,
Pool.Default);

GraphicsStream stm = vertexBuffer.Lock(0, 0, 0);
CustomVertex.TransformedColored[] verts =
new CustomVertex.TransformedColored[3];

verts[0].X = 150;
verts[0].Y = 50;
verts[0].Z = 0.5f;
verts[0].Rhw = 1;
verts[0].Color = System.Drawing.Color.Aqua.ToArgb();
verts[1].X = 250;
verts[1].Y = 250;
verts[1].Z = 0.5f;
verts[1].Rhw = 1;
verts[1].Color = System.Drawing.Color.Brown.ToArgb();
verts[2].X = 50;
verts[2].Y = 250;
verts[2].Z = 0.5f;
verts[2].Rhw = 1;
verts[2].Color = System.Drawing.Color.LightPink.ToArgb();
stm.Write(verts);
vertexBuffer.Unlock();
}
}

}
Dec 28 '07 #1
7 5632
On Fri, 28 Dec 2007 02:27:02 -0800, Gigs_ <gi**@hi.t-com.hrwrote:
im getting this tutorial:
http://einfall.blogspot.com/2005/02/...to-create.html

and i got some error, i dont know how to fix it.
What error do you get, exactly? How did you configure the project this
code is being compiled in? What's the target type?

Pete
Dec 28 '07 #2
On Dec 28, 10:46 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 28 Dec 2007 02:27:02 -0800, Gigs_ <g...@hi.t-com.hrwrote:
im getting this tutorial:
http://einfall.blogspot.com/2005/02/...-sharp-to-crea...
and i got some error, i dont know how to fix it.

What error do you get, exactly? How did you configure the project this
code is being compiled in? What's the target type?

Pete
Are you referencing the DirectX libraries?
But really as Pete says, unless you tell us the error it's very hard
to suggest what your problem might be.
Dec 28 '07 #3
Balaam wrote:
On Dec 28, 10:46 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
>On Fri, 28 Dec 2007 02:27:02 -0800, Gigs_ <g...@hi.t-com.hrwrote:
>>im getting this tutorial:
http://einfall.blogspot.com/2005/02/...-sharp-to-crea...
and i got some error, i dont know how to fix it.
What error do you get, exactly? How did you configure the project this
code is being compiled in? What's the target type?

Pete

Are you referencing the DirectX libraries?
But really as Pete says, unless you tell us the error it's very hard
to suggest what your problem might be.
Yes i reference directx.

I get

Unhandled Exception: System.BadImageFormatException: is not valid Win32
application. (Exception from HRESULT: 0x800700c1)
at VerticesTutorial.example.InitializeGraphics()
at VerticesTutorial.example.Main() in Aform.cs:line 18

im new to c# and visual studio so for project configure i dont know what you
mean. i just use empty project.

Dec 28 '07 #4
"Gigs_" <gi**@hi.t-com.hrwrote in message
news:fl**********@ss408.t-com.hr...
Balaam wrote:
>On Dec 28, 10:46 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
>>On Fri, 28 Dec 2007 02:27:02 -0800, Gigs_ <g...@hi.t-com.hrwrote:
im getting this tutorial:
http://einfall.blogspot.com/2005/02/...-sharp-to-crea...
and i got some error, i dont know how to fix it.
What error do you get, exactly? How did you configure the project this
code is being compiled in? What's the target type?

Pete

Are you referencing the DirectX libraries?
But really as Pete says, unless you tell us the error it's very hard
to suggest what your problem might be.

Yes i reference directx.

I get

Unhandled Exception: System.BadImageFormatException: is not valid Win32
application. (Exception from HRESULT: 0x800700c1)
at VerticesTutorial.example.InitializeGraphics()
at VerticesTutorial.example.Main() in Aform.cs:line 18

im new to c# and visual studio so for project configure i dont know what
you mean. i just use empty project.

What OS are you running this on? When running on a 64-bit os, you'll have to
change the target platform "MSIL" into "X86" in your project properties.
DirectX can only be used from 32-bit applications, so it's better to set the
target platform to "X86" even when running on a 32-bit OS.

Willy.

Dec 28 '07 #5
Willy Denoyette [MVP] wrote:
"Gigs_" <gi**@hi.t-com.hrwrote in message
news:fl**********@ss408.t-com.hr...
>Balaam wrote:
>>On Dec 28, 10:46 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 28 Dec 2007 02:27:02 -0800, Gigs_ <g...@hi.t-com.hrwrote:
im getting this tutorial:
http://einfall.blogspot.com/2005/02/...-sharp-to-crea...
>
and i got some error, i dont know how to fix it.
What error do you get, exactly? How did you configure the project this
code is being compiled in? What's the target type?

Pete

Are you referencing the DirectX libraries?
But really as Pete says, unless you tell us the error it's very hard
to suggest what your problem might be.

Yes i reference directx.

I get

Unhandled Exception: System.BadImageFormatException: is not valid
Win32 application. (Exception from HRESULT: 0x800700c1)
at VerticesTutorial.example.InitializeGraphics()
at VerticesTutorial.example.Main() in Aform.cs:line 18

im new to c# and visual studio so for project configure i dont know
what you mean. i just use empty project.


What OS are you running this on? When running on a 64-bit os, you'll
have to change the target platform "MSIL" into "X86" in your project
properties. DirectX can only be used from 32-bit applications, so it's
better to set the target platform to "X86" even when running on a 32-bit
OS.

Willy.
x64 is os. can you tell me exactly where can i change MSIL? im new to visual studio?

thanks!
Dec 28 '07 #6
"Gigs_" <gi**@hi.t-com.hrwrote in message
news:fl**********@ss408.t-com.hr...
Willy Denoyette [MVP] wrote:
>"Gigs_" <gi**@hi.t-com.hrwrote in message
news:fl**********@ss408.t-com.hr...
>>Balaam wrote:
On Dec 28, 10:46 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 28 Dec 2007 02:27:02 -0800, Gigs_ <g...@hi.t-com.hrwrote:
>im getting this tutorial:
>http://einfall.blogspot.com/2005/02/...-sharp-to-crea...
>and i got some error, i dont know how to fix it.
What error do you get, exactly? How did you configure the project
this
code is being compiled in? What's the target type?
>
Pete

Are you referencing the DirectX libraries?
But really as Pete says, unless you tell us the error it's very hard
to suggest what your problem might be.

Yes i reference directx.

I get

Unhandled Exception: System.BadImageFormatException: is not valid Win32
application. (Exception from HRESULT: 0x800700c1)
at VerticesTutorial.example.InitializeGraphics()
at VerticesTutorial.example.Main() in Aform.cs:line 18

im new to c# and visual studio so for project configure i dont know what
you mean. i just use empty project.


What OS are you running this on? When running on a 64-bit os, you'll have
to change the target platform "MSIL" into "X86" in your project
properties. DirectX can only be used from 32-bit applications, so it's
better to set the target platform to "X86" even when running on a 32-bit
OS.

Willy.
x64 is os. can you tell me exactly where can i change MSIL? im new to
visual studio?

thanks!

Project menu -project Properties -Build tab - Platform target "Any CPU"
select "X86" from the dropdown, rebuild the project when done.

Willy.
Dec 28 '07 #7
Willy Denoyette [MVP] wrote:
"Gigs_" <gi**@hi.t-com.hrwrote in message
news:fl**********@ss408.t-com.hr...
>Willy Denoyette [MVP] wrote:
>>"Gigs_" <gi**@hi.t-com.hrwrote in message
news:fl**********@ss408.t-com.hr...
Balaam wrote:
On Dec 28, 10:46 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
>On Fri, 28 Dec 2007 02:27:02 -0800, Gigs_ <g...@hi.t-com.hrwrote:
>>im getting this tutorial:
>>http://einfall.blogspot.com/2005/02/...-sharp-to-crea...
>>>
>>and i got some error, i dont know how to fix it.
>What error do you get, exactly? How did you configure the project
>this
>code is being compiled in? What's the target type?
>>
>Pete
>
Are you referencing the DirectX libraries?
But really as Pete says, unless you tell us the error it's very hard
to suggest what your problem might be.

Yes i reference directx.

I get

Unhandled Exception: System.BadImageFormatException: is not valid
Win32 application. (Exception from HRESULT: 0x800700c1)
at VerticesTutorial.example.InitializeGraphics()
at VerticesTutorial.example.Main() in Aform.cs:line 18

im new to c# and visual studio so for project configure i dont know
what you mean. i just use empty project.

What OS are you running this on? When running on a 64-bit os, you'll
have to change the target platform "MSIL" into "X86" in your project
properties. DirectX can only be used from 32-bit applications, so
it's better to set the target platform to "X86" even when running on
a 32-bit OS.

Willy.
x64 is os. can you tell me exactly where can i change MSIL? im new to
visual studio?

thanks!


Project menu -project Properties -Build tab - Platform target "Any
CPU" select "X86" from the dropdown, rebuild the project when done.

Willy.

thanks mate, its working now. :-)
Dec 29 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark Space | last post by:
Hi all, I followed some simple instructions to add python scrips to IIS as a cgi. The instructions were here: http://www.e-coli.net/pyiis.html Unfortunately, when I try to run a test script,...
1
by: greg grosiak | last post by:
Hello, I am tring to downloand a character file from microsoft agent website. I download the animated character peedy and when I try and run the exec it gives me an error not a valid win32...
2
by: Woody | last post by:
Tried to run the new sqlexpress and got a not valid win32 msg. So i tried to load the dot net and got this for an error. Help
1
by: Pradeep D | last post by:
Hi, We have a .net dll, which has a wrapper to command line tool. When we try to call we enocunter this error. When we execute the same command from command line it executes without error. Can...
1
by: Pradeep D | last post by:
Hi, We have a .net dll, which has a wrapper to command line tool. When we try to call we enocunter this error. When we execute the same command from command line it executes without error. Can...
0
by: Tom | last post by:
I can't debug my asp.net projects. for some reason i'm getting an error saying that i don't have permission and i should be added to the debuggers group. I added my domain user, my aspnet user and...
6
by: =?Utf-8?B?TWVsaXNzYQ==?= | last post by:
I was having a problem on my computer and had to uninstall and re-install iis. Now I am trying to re-register asp.net using aspnet_regiis.exe -i but the computer just gives me the error message...
2
by: rtskarthik | last post by:
Hi All, I am unable to compile a windows application. I am using .Net 2003.I get the error "F:\....\obj\Debug\CSC15.tmp' is not a valid Win32 resource file". I have stuck with this problem. Even...
7
by: Boris | last post by:
I have a mixed DLL (a managed DLL in C++ calling functions in other unmanaged DLLs) which I can build successfully in Visual Studio 2005 but can't reference as I get then immediately the error: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.