2017-02-27 3 views
-2

Ich habe mich in anderen Foren umgesehen und kann die Antwort nirgendwo finden. Kann mir jemand helfen?CS5001 Programm enthält keine statische 'Main' Methode für einen Einstiegspunkt

static void Main(string[] args) { 
    csProcess = Process.GetProcessesByName("notepad").FirstOrDefault(); 
    if (csProcess == null) { return; } // notepad isn't running 
    modules = csProcess.Modules; 
    foreach(ProcessModule module in modules) { 
     if (module.ModuleName == "client.dll") { 
      int ClientDLL = Mem.Module("client.dll"); 
     } 

     int LocalPlayer = ReadProcessMemory(ClientDLL + m_dwLocalPlayer); 
     int LocalTeam = ReadProcessMemory(LocalPlayer + m_iTeamNum); 
     int CrossHairID = ReadProcessMemory(LocalPlayer + m_iCrossHairID); 
     int EmemyinCrossHair = ReadProcessMemory(ClientDLL + m_dwEntityList + 
      ((CrossHairID - 1) * EntLoopDist)); 
     int EnemyTeam = ReadProcessMemory(EnemyInCrossHair + m_iTeamNum); 
     int EnemyHealth = ReadProcessMemory(EnemyinCrossHair + m_iHealth); 

     if (EnemyHealth > 0 && EnemyTeam != LocalTeam) { 
      mouse_event(MOUSEEVENTF_LEFTDOWN, Control.MousePosition.X, 
       Control.MousePosition.Y, 0, 0); 
      mouse_event(MOUSEEVENTF_LEFTUP, Control.MousePosition.X, 
       Control.MousePosition.Y, 0, 0); 
     } 
    } 
} 

Ich brauche Schritt für Schritt Anweisungen bitte.

+0

Überprüfen Sie 'Build Action' &' Output Type' auf Projekteigenschaften, dann prüfen Sie die Verfügbarkeit der 'App.xaml' Datei. Welche möchten Sie erstellen: eine WinForms-App, eine Konsolen-App oder eine Klassenbibliothek? –

+0

Ich möchte als dll so exportieren ... Konsole? –

+0

Versuchen Sie, die Klassenbibliothek als Ausgabetyp in Project => Properties zu verwenden (beachten Sie, dass sie standardmäßig als Konsolenanwendung erstellt werden kann). Für die Konsolen-App muss 'STAThreadAttribute' mit der' Main'-Methode ausgeführt werden (siehe ähnliches Problem: http://stackoverflow.com/questions/9607702/does-not-contain-a-static-main-method-suitable-for-an- Einstiegspunkt). –

Antwort

0

Was möchten Sie bekommen? Dll-Bibliothek oder eigenständige Anwendung (. Exe-Datei, Konsole App)?
Wenn Sie exe-Anwendung erhalten möchten, versuchen public Modifikator für Main-Methode hinzufügen - public static void Main(string[] args)
DLL-Bibliothek:
1. Neues Projekt erstellen „Klassenbibliothek“ Typ.
2. Sie haben bereits eine Datei Class1.cs. Ersetzen Sie den Text in dem Class1.cs:

namespace ClassLibrary1 
{ 
    public static class Class1 
    { 
     static void MyMethod() 
     { 
      csProcess = Process.GetProcessesByName("notepad").FirstOrDefault(); 
      //Your another code 
     } 
    } 
} 

3. Build-Projekt und verwenden ClassLibrary1.dll von bin-> Debug oder sind-Release-Ordner, indem Sie diesen DLL als Referenz in Console/WinForms/WPF-Anwendungen.
4. Verwenden Sie Ihre DLL-Klasse wie folgt - ClassLibrary1.Class1.MyMethod();

+0

Ich habe dies getan, und alles ist jetzt in Fehlermeldungen umgeben. –

Verwandte Themen