Announcement

Collapse
No announcement yet.

Dll Probleme

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dll Probleme

    Habe folgendes Problem:
    Ich habe schon mehrmals mittels DllImport dlls in meinen C# Projekten verwendet.. allerdings bekomme ich jetzt haufenweise Kompilierfehler wenn ich versuche mittels
    [DllImport("user32.dll",EntryPoint="FindWindow")]
    private static extern int FindWindow(string _ClassName, string _WindowName);

    user32.dll einzubinden.
    System.Runtime.InteropServices ist eingebunden.. und ein älteres Projekt verwendet denselben Code, kann allerdings immer noch kompiliert werden.

    Fehler:
    c:\reflection_test\WindowsApplication2\Form1.cs(79 ): Invalid expression term '['
    c:\reflection_test\WindowsApplication2\Form1.cs(79 ): ; expected
    c:\reflection_test\WindowsApplication2\Form1.cs(79 ): ; expected
    c:\reflection_test\WindowsApplication2\Form1.cs(79 ): Invalid expression term ']'
    c:\reflection_test\WindowsApplication2\Form1.cs(79 ): ; expected
    c:\reflection_test\WindowsApplication2\Form1.cs(80 ): Invalid expression term 'private'
    c:\reflection_test\WindowsApplication2\Form1.cs(80 ): ; expected
    c:\reflection_test\WindowsApplication2\Form1.cs(80 ): Invalid expression term 'static'
    c:\reflection_test\WindowsApplication2\Form1.cs(80 ): ; expected
    c:\reflection_test\WindowsApplication2\Form1.cs(80 ): Invalid expression term 'extern'
    c:\reflection_test\WindowsApplication2\Form1.cs(80 ): ; expected
    c:\reflection_test\WindowsApplication2\Form1.cs(80 ): Expected ; or = (cannot specify constructor arguments in declaration)
    c:\reflection_test\WindowsApplication2\Form1.cs(80 ): Invalid expression term 'string'
    c:\reflection_test\WindowsApplication2\Form1.cs(80 ): Invalid expression term 'string'

  • #2
    Noch mal: der Fehler taucht während Kompilation auf oder wenn das Programm läuft?
    <br>
    Sonst, versuch mal : <br>
    ...EntryPoint="FindWindowA"..

    Comment


    • #3
      taucht während der kompilation auf.

      Comment


      • #4
        Hallo,

        &gt;..Invalid expression term '['..

        diese Fehlermeldung deutet darauf hin, dass die Importfunktion mit dem DllImport-Attribut an einer "falschen" Stelle im Sourcecode deklariert wird (siehe Zeile 79, das sieht nach "Windows Form Designer generated code" aus). Wie sieht ein Minimal-Beispiel (so wenige Zeilen wir nur möglich) aus, mit dem sich dieser Effekt reproduzieren lässt

        Comment


        • #5
          habe das problem mittlerweile gelöst..<br>
          ich hatte das attribut in einer funktion die beim drücken eines buttons aufgerufen wurde.. jetzt ist das import attribut am programm-anfang und alles läuft.<br>
          danke für die hilf

          Comment

          Working...
          X