0

I'm new to programming and C#, I am attempting to write a program that detects errors or server crashes from my battlefield 2 server, it will then shut the server down (if the server is not already down) and start it back up but I have ran in to a small bump. When I try to start battlefield 2 back up again I receive this error from bf2:

Debug assertion failed! Version 1.0.2446.12 Build date:
Module: Python
File: c:\dice\Projects\BF2Branches\BF2Demo\Code\BF2\Game\Python\PythonHost.Cpp
Line:243

Text: couldn't import the bf2 module:

Current confile:

The path in the error doesn't exist.

I have researched a couple different ways to start up an application but they all have the same results. These are a couple I have tried so far:

Process proc = new Process();
proc.StartInfo.FileName = @"txtServerPath.Text";
proc.Start();

and

Process.Start(txtServerPath.Text);

When I manually start the bf2 Server it starts fine. So what am I doing wrong?
My program will be ran from both Windows Server 2003 and Windows 7 if that matters.

IZZO
  • 1
  • 1

1 Answers1

0

Debug assertion failed! Version 1.0.2446.12 Build date: Module: Python File: c:\dice\Projects\BF2Branches\BF2Demo\Code\BF2\Game\Python\PythonHost.Cpp Line:243

Text: couldn't import the bf2 module:

Current confile:

The path in the error does not exist because it is the path on the machine on which PythonHost.cpp was written. 'Debug assertion' means that the developer of the code put a condition check at the specified line number in the cpp file to check for a certain condition to be sure that 'everything works fine.' but obviously it isn't. It seems strange though that BF2 has installed a debug version.

Anyhow, your process does start but it errors out. And the problem, it seems is that it is unable to find a python module named 'bf2' when you start the process from within C#.

So first and foremost verify that {BF2 Install folder}\python\bf2\ __init__.py exist.

In order to gain more insight on why this might be happening, try to start BF2 like this (assuming your C# application is a console application):

Process bf2 = new Process();
bf2.StartInfo.FileName = @"C:\Program Files\EA Games\Battlefield 2\BF2.exe";
bf2.StartInfo.Arguments = "+debugOutput 1";
bf2.StartInfo.UseShellExecute = false;
bf2.StartInfo.RedirectStandardOutput = true;
bf2.StartInfo.RedirectStandardError = true;
bf2.Start();    

Console.WriteLine(bf2.StandardOutput.ReadToEnd());
Console.WriteLine(bf2.StandardError.ReadToEnd());

This should print some logs on the console going through which, I suspect, something useful can be deduced.

By the way can you post the remaining error message (i.e. after 'Current confile:' line)

Amit Mittal
  • 2,646
  • 16
  • 24
  • That was the full error that bf2 gave. I am using windows form so i changed it up a little Bf2 is now giving me a different error but nothing is being printed out to the logs. Debug assertion failed! Version 1.0.2446.12 Build date: module:Main File: c:\dice\Projects\BF2Branches\BF2Demo\Code\BF2\Game\Main\StatusMonitorImpl_win32.cpp Line:107 Text: couldn't set console window size current confile: The __init__.py does exist. – IZZO Jul 10 '12 at 01:50
  • Sorry for the formatting on the above comment. The commenting seems to be a little odd on this site and it wont let me edit it. – IZZO Jul 10 '12 at 02:00