Hello,
I want to write a unittest that compares
the property-values of a managed-object with
the property-values of an object instantiated via interop.
Background is:
I have a vb6-class with many public properties. The properties will be
filled by a Read-method from a file and can be written to a file by a
write-method.
Then I converted the vb6-code with upgrade-wizard to VB.NET.
Now I want a use case that instantiates these two classes,
the "old" via interop and the "new" one.
Then get via reflection the propertynames and values, interate about
them and compare the values.
The managed part is no problem with reflection, but
the first problem was that the activeX-instance does not have the
GetType() method.
Ok ... then I found this posting:
http://groups.google.de/group/microsoft.public.dotnet.framework/browse_thread/th
read/10c9516762808b3d/52447f5e8683c33d?lnk=st&q=createinstance+interop+oMethod&r
num=1&hl=de#52447f5e8683c33d
With that idea I tried:
oAssembly = oAssembly.LoadFrom("Interop.TestObject06.dll")
oObj =
Activator.CreateInstance(oAssembly.GetType("TestObject06.CTestObject06Class"))
There is the problem that CreateInstance throws a
MissingMethodException and tells
that it cannot create an instance of an interface.
Mhmmm... Then I tried:
oObj =
Activator.CreateInstance(oAssembly.GetType("TestObject06.CTestObject06Class"),
BindingFlags.IgnoreReturn)
There is the problem that CreateInstance throws also a
MissingMethodException and tells
that that the constructor for "TestObject06.CTestObject06Class" cannot
be found.
I suppose "constructor" means in this case:
Public Sub Class_Initialize()
End Sub
But this piece of code is in in the vb6.class.
........
Now i am a bit confused.
Is it possible to get the properties of an activex-dll via interop?
Thanks
Gordian
Mattias Sjögren - 25 Jan 2007 18:54 GMT
>oAssembly = oAssembly.LoadFrom("Interop.TestObject06.dll")
>oObj =
[quoted text clipped - 3 lines]
>MissingMethodException and tells
>that it cannot create an instance of an interface.
The typelib importer creates an interface with the same name as the
imported coclass, and then a class with "Class" appended to the name.
So try oAssembly.GetType("TestObject06.CTestObject06ClassClass")
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
cit42@web.de - 26 Jan 2007 07:39 GMT
> imported coclass, and then a class with "Class" appended to the name.
> So try oAssembly.GetType("TestObject06.CTestObject06ClassClass")
That's it!
I didn't notice the postfix "Class" and its meaning.
Now it works.
Thank You
Gordian