Esempio n. 1
0
        LoadBuiltinModule(string name)
        {
            IntPtr           initFP = Unmanaged.GetProcAddress(this.library, "init" + name);
            PydInit_Delegate init   = (PydInit_Delegate)Marshal.GetDelegateForFunctionPointer(initFP, typeof(PydInit_Delegate));

            init();
        }
Esempio n. 2
0
        Load(string path)
        {
            // the ActCtx stuff allows us to import .pyds which link to msvcr90 but don't have manifests
            // implementation explained in stub/ic_msvcr90.c
            IntPtr cookie = Unmanaged._Py_ActivateActCtx();
            IntPtr l      = Unmanaged.LoadLibrary(path);

            Unmanaged._Py_DeactivateActCtx(cookie);

            if (l == IntPtr.Zero)
            {
                throw new Exception(
                          String.Format("Could not load library '{0}' . Error code:{1}", path, Unmanaged.GetLastError()));
            }

            this.handles.Add(l);
            string funcName = "init" + Path.GetFileNameWithoutExtension(path);
            IntPtr funcPtr  = Unmanaged.GetProcAddress(l, funcName);

            if (funcPtr == IntPtr.Zero)
            {
                throw new Exception(
                          String.Format("Could not find module init function {0} in dll {1}", funcName, path));
            }

            PydInit_Delegate initmodule = (PydInit_Delegate)Marshal.GetDelegateForFunctionPointer(
                funcPtr, typeof(PydInit_Delegate));

            initmodule();
        }