Wade Tandy
Wade Tandy

Reputation: 4144

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.

Upvotes: 3

Views: 3076

Answers (1)

Bryan Watts
Bryan Watts

Reputation: 45445

formInstance.GetType().Assembly

Edit in response to comment:

from form in Application.OpenForms
where form.Owner != null
select form.Owner.GetType().Assembly

Upvotes: 11

Related Questions