Domanda

Ecco un'interfaccia molto semplice IDL che abbiamo usato con successo sotto VS2008 (argomenti elenco ridotto per brevità):

interface Mailer
{
    string findNode( [in] string requestedNode );
    unsigned short addMessage( [in] string msg, [in] unsigned short kind );
};

Stiamo migrazione la soluzione per VS2010 SP1. Ora abbiamo il seguente errore di generazione:

M.idl(3): error MIDL2025: syntax error : expecting a type specification near "string"

Questo sempre funzionato come un fascino utilizzando VS2008 SP1 Si noti che ho già sostituito in da [in]. Mentre graffiare la mia testa, ho scoperto che sugli istituti 2010 antipatia anche in ma non dice nulla circa [in].

Si noti che unsigned short è accettata (come osservato invertendo i 2 metodi dell'interfaccia).

Come mai? Come posso fare sugli istituti capire di nuovo string?

TIA.

È stato utile?

Soluzione 3

It appears that the IDL file, although present in the project, isn't used at all. VS2008 silently ignored it (as it would do for an unreferenced .h file). For some reason, VS2010 tries to compile it even if it's not referenced anywhere else. And since the contents is totally buggy (string is indeed not a native IDL type but an attribute as best), I now have errors.

Solution: Exclude file from project!

Altri suggerimenti

Looks like compiler doesn't know about type 'string', maybe you forgot to include some reference in project, or it's location changed in VS2010, etc. Double check for includes, references and a like.

P.S. Does that makes sense?

For exposing from C# ,this:

  interface Mailer
    {
        [return, MarshalAs(UnmanagedType.BStr)]
        string findNode( [In, MarshalAs(UnmanagedType.BStr)] string requestedNode );
        unsigned short addMessage( [In, MarshalAs(UnmanagedType.BStr)] string msg, [in] unsigned short kind );
    };

I saw that you possibly mean exposing it from C++:

interface Mailer
{
    HRESULT findNode( [out, retval] BSTR* result, [in] BSTR requestedNode );
    HRESULT addMessage( [out, retval] unsigned short* result, [in] BSTR msg, [in] unsigned short kind );
};
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top