Click here to Skip to main content
15,904,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've looked all over the web for answers on how to get struct types from an assembly (".dll" or ".exe") but can't find anything.
I know that it requires the System.Reflection namespace but don't know how to construct and function to return a list of structs.
Posted
Comments
Sergey Alexandrovich Kryukov 6-Apr-14 23:32pm    
.dll or .exe is not an assembly, it can be an assembly executable module. What do you mean by "get types".
—SA

Using reflection loop through the class details and use the following condition -
type.IsValueType && !type.IsPrimitive && !type.Namespace.StartsWith("System") && !type.IsEnum.

It should help you get a list of structs used in the class.

If you want an example on reflection, try Accessing Attributes by Using Reflection[^]. A similar approach is needed for reading other types as well.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 6-Apr-14 23:36pm    
Abhinav,

I don't know why are you showing this. You do something with the instance of type, but why? The question was on how to get the types themselves. Please see my answer.

—SA
Abhinav S 7-Apr-14 1:54am    
The OP is looking for a solution that uses reflection.
Sergey Alexandrovich Kryukov 7-Apr-14 2:06am    
I can only repeat what I just said. I answered and explained what to do with reflection.
—SA
This is how: http://msdn.microsoft.com/en-us/library/system.reflection.assembly.gettype.aspx[^].

You need to learn reflection, if you want to move in this direction. And learn how to find what you need in documentation. I guess next your question would be what to do with a types when you found some. :-)

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900