2012-09-03 2 views
18

ho il seguente codice:Manca DllImport anche se non c'è un "utilizzando InteropServices"

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.InteropServices; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using MapsApp.DB; 

namespace MapsApp 
{ 
    public partial class _Default : System.Web.UI.Page 
    { 
     [DLLImport("GeoUrbanApp.exe")] 
     public static extern double CalcFigure(double east, double north, double size); 
... 

Sto cercando di chiamare la funzione CalcFigure dal exe. L'ho aggiunto nei riferimenti e provando a importarlo. Tutto quello che ottiene è:

The type or namespace name 'DLLImport' could not be found (are you missing a using directive or an assembly reference?) 

The type or namespace name 'DLLImportAttribute' could not be found (are you missing a using directive or an assembly reference?) 

la soluzione più persone a trovare on-line è il "using System.Runtime.InteropServices;" ma ce l'ho

risposta

27

E 'DllImport Non DLLImport

:)

+0

Eh, grazie, lei ha ragione! L'ho preso da una delle risposte su StackOverflow, apparentemente questa persona non era cauta in ciò che scriveva. – Vadiklk

46

Prova ad aggiungere "using System.Runtime.InteropServices;" alla classe, che è lo spazio dei nomi risiede il DllImportAttribute in.

Razie