dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]PInvoke question...


From: Gopal V
Subject: Re: [DotGNU]PInvoke question...
Date: Fri, 11 Jul 2003 13:35:22 +0530
User-agent: Mutt/1.2.5i

If memory serves me right, Mark Easton wrote:
> Stupid me - of course you are right that Winelib doesn't run on PPC, or
> anything other than x86 for that matter. 

K, I was just asking ... (there is no real reason why winelib shouldn't
be ported to PPC as a library, ie MFC like API using X11)

> Now it's certainly useful to know that dynlib.c is dealing with loading
> dynamic libs and the error msg is certainly useful for answering stupid
> emails from newbies like me.  However, I was under the assumption that
> all error messages should be pushed through as .NET exceptions rather
> than being written directly to the error stream?  

The error is pushed out as an exception ... or it should be :) ...

The exact exception is thrown from 

pnet/engine/convert.c:438
                        case IL_CONVERT_MISSING_METHOD:
                        {
                                ILExecThreadSetException
                                        (thread, _ILSystemException(thread, 
                                                
"System.MissingMethodException"));
                        }
                        break;

tracing back ...

pnet/engine/convert.c:220
                                moduleHandle = LocateExternalModule
                                                                        
(thread->process, name, pinv);
                                if(!moduleHandle)
                                {
                                        METADATA_UNLOCK(thread);
                                        *errorCode = IL_CONVERT_MISSING_METHOD;
                                        return 0;
                                }

pnet/engine/convert.c:82
        /* Attempt to open the module */
        loaded->handle = ILDynLibraryOpen(pathname);
        ILFree(pathname);
        return loaded->handle;

going on to ...

> pnet/support/dynlib.c:73
>                       case NSObjectFileImageFormat:
>                               msg = " (NSObjectFileImageFormat)";
> break;
>                       case NSObjectFileImageAccess:
>                               msg = " (NSObjectFileImageAccess)";
> break;
>                       default:
>                               msg = ""; break;
>               }
>               fprintf(stderr, "%s: could not load dynamic
> library%s\n", name, msg);

I'm quoting all this so you can see how support and the engine are linked
up together ...


> Now my big problem is that it doesn't seem to be throwing any kind of
> .NET exception at the moment, so I guess I might have a little browse to
> see how dynlib.c fits into the equation

try
{
        Native.ThisMethodDoesNotExist();
        // or some other silly example method !
}
atch(Exception err)
{
        Console.WriteLine(err.ToString());
}

Try this on pnet to get a MissingMethodException... if you don't
then it's time to panic ;-)

But I think OS X's Pinvoke stuff was very well tested when X11# was
ported... and winforms demo'd out ..

Gopal
-- 
The difference between insanity and genius is measured by success


reply via email to

[Prev in Thread] Current Thread [Next in Thread]