Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Find The Owning Assembly Of An Object In C#

I'm trying to do some processing on all assemblies that own forms that are currently open in my application. I can easily get the form objects with:

System.Windows.Forms.Application.OpenForms

I want to iterate through this list and find the owning assembly for each instance. I know how to find the assembly that owns a given form class, but not a specific class instance.

like image 752
Wade Tandy Avatar asked Nov 20 '25 16:11

Wade Tandy


1 Answers

formInstance.GetType().Assembly

Edit in response to comment:

from form in Application.OpenForms
where form.Owner != null
select form.Owner.GetType().Assembly
like image 87
Bryan Watts Avatar answered Nov 23 '25 05:11

Bryan Watts