Hallo zusammen,
ich kann keine grafischen Oberflächen mit dem Visual Studio anfertigen.
Wenn ich eine leere Form erstelle und diese gleich kompiliere und laufen lasse, erhalte ich folgende Fehlermeldung:
Unhandled Exception: System.Runtime.InteropServices.COMException (0x800700B7): Cannot create a file when that file already exists.
at System.Windows.Forms.UnsafeNativeMethods.WaitMessage()
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsApplication8.Form1.Main(String[] args) in e:\budev\reader\windowsapplication8\form1.cs:line 19_
weiß vielleicht jemand woran das liegen könnte?_
In Zeile 19 scheint der Fehler zu liegen. Zeige doch mal deinen Code. Was erstellst du denn, wenn du Neuen Projekt erstellen wählst?
Code-Hacker
Anbei der Quellcode.
Es handelt sich zwar in diesem Fall nicht um den Code, der von Visual Studio automatisch generiert wird, sondern um ein Beispiel von MS. Es kommt aber in beiden Fällen die identische Fehlermeldung.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication8
{
/// <summary>
/// Zusammendfassende Beschreibung für Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
public ListBox listBox1;
public static void Main(string[] args)
{
// Starts the application.
Application.Run(new Form1());
}
protected void button1_Click(object sender, System.EventArgs e)
{
// Populates a list box with three numbers.
int i = 3;
for(int j=1; j<=i; j++)
{
listBox1.Items.Add(j);
}
/* Checks to see whether the user wants to exit the application.
* If not, adds another number to the list box. */
while (MessageBox.Show(>Exit application?>, >>, MessageBoxButtons.YesNo) == DialogResult.No)
{
// Increment the counter and add the number to the list box.
i++;
listBox1.Items.Add(i);
}
// The user wants to exit the application. Close everything down.
Application.Exit();
}
}
}
[Editiert von Code-Hacker 15:19 Uhr]
Code Tags eingefügt! Bitte dran denken, danke!
Verwendung: [codeX] [/codeX] (X natürlich weglassen)
Hmmm....es fehlt die Methode InitializeComponents und der von der IDE erstellte Code. Erstelle mal eine neue Windowsanwendung, kopiere die Methode button1_Click dort ein und weise sie einem Button zu. Dann versuche es nochmal.
Code-Hacker
Ok, ich habe jetzt nochmals eine neue Anwendung erstellt. Das mit dem Button habe ich weggelassen, da es nichts mit dem Fehler zu tun hat. Hier der automatisch generierte Code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication9
{
/// <summary>
/// Zusammendfassende Beschreibung für Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Erforderlich für die Windows Form-Designerunterstützung
//
InitializeComponent();
//
// TODO: Fügen Sie den Konstruktorcode nach dem Aufruf von InitializeComponent hinzu
//
}
/// <summary>
/// Die verwendeten Ressourcen bereinigen.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = >Form1>;
}
#endregion
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
wirft beim ausführen nach ca. 2 Sekunden folgende Fehlermeldung:
_
Unhandled Exception: System.Runtime.InteropServices.COMException (0x800700B7): Cannot create a file when that file already exists.
at System.Windows.Forms.UnsafeNativeMethods.WaitMessage()
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsApplication9.Form1.Main() in e:\budev\reader\windowsapplication9\form1.cs:line 66_
Also bei mir laufen beide Win-Apps. ohne Probleme!
Ausser das WindowsApplication8, kein Button-Objekt hat.
Ich empfehle Dir, VS.Net und wenn nötig, die erforderlichen Komponenten neu zu installieren!
Was für Versionen hast Du drauf?
Ich verwende:
VS.Net 2003
.Net Framework SDK 1.1
Gruss,
Steff
Original von Killron
_
Unhandled Exception: System.Runtime.InteropServices.COMException (0x800700B7): Cannot create a file when that file already exists._
Mach noch einmal ein neues Projekt, aber diesmal auf Laufwerk C oder so.
Steff
Hallo
Ich habe das oben einfach in ein Wordpad Dokument eingefügt z.b. test.cs
und dann per csc.exe test.cs übersetzt und läuft?
MFG
könnte es sein das deine Auslagerungsdatei zu klein ist oder das du Probelme mit deinem RAM hast?