Using GetTypes() with an IKVMC DLL - not a question, just an observation/tip
Paul Chambre <[email protected]> Wed, 28 Jun 2017 08:20:33 -0600
| Newsgroups | gmane.comp.java.ikvm.devel |
|---|---|
| Message-ID | <CAJwVo5FKeOX3xqK8RRMp-orAoFtbX35c9fvt_uK-zNnvBvj9rA@mail.gmail.com> |
--===============0506786327418445129==
Content-Type: multipart/alternative; boundary="001a114577301ce16b055305e311"
--001a114577301ce16b055305e311
Content-Type: text/plain; charset="UTF-8"
I was trying to enumerate the types (classes) incorporated into my IKMVC
DLL, so I could be sure I wasn't including unnecessary jars. I could easily
browse the types using the Object Browser in Visual Studio, but this
doesn't provide a way to export to text.
Most Google searches returned articles suggesting various forms of loading
an assembly with Reflection and then calling GetTypes() and iterating the
result. Every variant of that that I tried resulted in a set of
non-continuable load errors.
Finally, I chanced onto a couple of blog updates about IKVM Reflection. I
changed my type enumerator app to use this, instead of .NET's own
Reflection implementation, and it worked great. I'm still not sure why the
Object Browser has no problem, while regular Reflection does; but, if you
need to do this type of thing, IKVM's Reflection seems to be the solution.
Snippet:
IKVM.Reflection.Universe iru = new IKVM.Reflection.Universe();
IKVM.Reflection.Assembly dll =
iru.LoadFile(txtDLLFileName.Text);
IKVM.Reflection.Type[] dlltypes = dll.GetTypes();
Cheers,
Paul
--001a114577301ce16b055305e311
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I was trying to enumerate the types (classes) incorporated=
into my IKMVC DLL, so I could be sure I wasn't including unnecessary j=
ars. I could easily browse the types using the Object Browser in Visual Stu=
dio, but this doesn't provide a way to export to text.=C2=A0<div><br></=
div><div>Most Google searches returned articles suggesting various forms of=
loading an assembly with Reflection and then calling GetTypes() and iterat=
ing the result. Every variant of that that I tried resulted in a set of non=
-continuable load errors.=C2=A0</div><div><br></div><div>Finally, I chanced=
onto a couple of blog updates about IKVM Reflection. I changed my type enu=
merator app to use this, instead of .NET's own Reflection implementatio=
n, and it worked great. I'm still not sure why the Object Browser has n=
o problem, while regular Reflection does; but, if you need to do this type =
of thing, IKVM's Reflection seems to be the solution.</div><div><br></d=
iv><div>Snippet:=C2=A0</div><div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 IKVM.Reflection.Universe iru =3D new IKVM.Reflection.Universe();</di=
v><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 IKVM.Reflection.Assembly d=
ll =3D iru.LoadFile(txtDLLFileName.Text);</div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 IKVM.Reflection.Type[] dlltypes =3D dll.GetTypes();</d=
iv><div><br></div><div>Cheers,</div><div>Paul</div>
</div></div>
--001a114577301ce16b055305e311--
--===============0506786327418445129==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--===============0506786327418445129==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Ikvm-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ikvm-developers
--===============0506786327418445129==--