Ask Your Question
2

Is there a way to programmatically check whether a DLL exists in the GAC (Global Assembly Cache) and display it in a grid if it does?

asked 2022-05-06 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-10-08 17:00:00 +0000

bukephalos gravatar image

Yes, there is a way to programmatically check whether a DLL exists in the GAC and display it in a grid.

First, you need to refer the System.EnterpriseServices.Internal namespace in your code. Then, you can use the AppsInterop class to check whether the DLL exists in the GAC by passing the DLL name as an argument to the IsInGac method.

If the method returns true, you can get the DLL details using the GetClassInfo method of the same class. You can then display the DLL details in a grid or any other UI component.

Here is some sample code to demonstrate this:

using System.EnterpriseServices.Internal;

// ...

string dllName = "MyAssembly.dll";  // Change this to the name of your DLL

if (AppsInterop.IsInGac(dllName))
{
    var classInfo = AppsInterop.GetClassInfo(dllName);

    // Display the class info in a grid or any other UI component
    // classInfo.Name contains the name of the class
    // classInfo.Version contains the version number of the assembly
    // classInfo.AssemblyName contains the full name of the assembly
}
else
{
    // Display a message indicating that the DLL is not found in the GAC
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-05-06 11:00:00 +0000

Seen: 7 times

Last updated: Oct 08 '21