InvalidProgramException

I have a mixture of VC++ 6.0 and C# .NET 2.0 project.
I have a COM class which is a collection in VC++, I implement IList, ICollection and IEnumerable which are com visible in the CoClass.

Then I tried to use the com object in .NET, as It derives from ICollection I can should simply use its methods but whenever I call any method of the Com object I receive a InvalidProgramException. (This exception occurs before calling because I put a breakpoint in VC)

I checked q312544 at support.microsoft.com as mentioned in MSDN but it was not helpful for me. I also usedPEVerify on my application and have no error.

How can I solve it?

[736 byte] By [MReza(MohammadRezaJooyandeh)] at [2008-1-10]
# 1
Are you running on a 64-bit OS? Project + Properties, Build tab, Platform target = x86.
nobugz at 2007-10-3 > top of Msdn Tech,.NET Development,Common Language Runtime...
# 2
nobugz wrote:
Are you running on a 64-bit OS? Project + Properties, Build tab, Platform target = x86.

No! But I finally get the point.

I have such a code

interface IMyCollection: ICollection<MyType>, ICollection
{
...
};

and I exported it and implement it VC but ofcourse the template parent wouldn't be exported.
I implement the non generic ICollection in CoClass. but when I called the property Count of my recieved object in .NET. It called ICollection<MyType> and it causes the exception!
I cast my object to non generic ICollection and the problem has solved.

.NET Development

Site Classified