> If the put the code,
>
[quoted text clipped - 11 lines]
> {
> IntPtr ptr = Marshal.AllocCoTaskMem(4);
I don't see that you free that memory anywhere in the code...
> hr = em.Next(monikers.Length, monikers, ptr);
> x = Marshal.ReadInt32(p);
Where does the p variable come from?
> // Use x below
> ...
> ...
> Marshal.FreeCoTaskMem(p);
If you free the memory that p points to, and then try to access it in
the next iteration of the loop, that memory area may have been allocated
to another process. That would definitely cause an access violation.
> }
>
[quoted text clipped - 3 lines]
> Thanks!
> DH

Signature
Göran Andersson
_____
http://www.guffa.com