Tuesday, May 31, 2011

Get .Net assembly full name using built-in Windows features without Reflector

If you work with Sharepoint then most probably quite often you need to know assembly full name (e.g. for adding it to the Assembly directive on your application layout page). Until the recent time preferred way for me to investigate assembly full name was .Net Reflector: load assembly under question in it and check full name in the bottom of the window:

image

However as you probably know Red gate announced that starting from version 7.0 Reflector will be payable. They leave version 6.8 as last version available for free. However I was a bit surprising when didn’t find this feature in version 6.8:

image

May be I missed something but I didn’t find how to enable this feature in v.6.8. Or it was made intentionally in order to attract more users to the new version – I don’t know. And although I personally don’t like idea to make Reflector payable, I won’t claim to the Red gate. I just wanted to find a workaround for the missing functionality using built-in tools.

Of course you can go to the GAC (C:\Windows\assembly)  and check properties of the assembly:

image

Then combine full name from file name, version, culture and public key token. However this way is not very convenient. The better way is to copy full name at one operation.

It can be done with PowerShell – built-in script engine in Windows. Go to Start and type PowerShell in the “Search programs and files”. Then add one line of code:

   1: PS C:\> [System.Reflection.AssemblyName]::GetAssemblyName("MyAssembly.dll").FullName

It will print full name of the assembly into the console. Also you can use path to the GAC:

   1: PS C:\> [System.Reflection.AssemblyName]::GetAssemblyName("C:\Windows\assembly\GAC_MSIL\Microsoft.SharePoint.Publishing\14.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Publishing.dll").FullName
   2: Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

May be this method is not so convenient as graphic UI tool, however it doesn’t require neither installation of external software nor development of custom tool. Hope it will be helpful. If you will find more easy ways to investigate assemblies full names it will be cool if you will share it in comments to this post as well.

6 comments:

  1. Hi,

    You can get your assembly fully qualified name with running utility listed here(
    http://tinyurl.com/5rrqgoy). Hope you will find it useful.

    Thanks,
    Ashish

    ReplyDelete
  2. AshishChotalia,
    the main idea of the post was how to make it using built-in features without development. It is not hard to create a custom tool for that (2 lines of code I guess :) )

    ReplyDelete
  3. What happens using .NET 4.0 assemblies and powershell ? I get error "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

    ReplyDelete
  4. Kiquenet,
    check this thread: http://stackoverflow.com/questions/2094694/how-can-i-run-powershell-with-the-net-4-runtime.

    ReplyDelete
  5. If you want to use one line PowerShell command follow a blog here
    http://faisalrafique.wordpress.com/2013/01/16/how-to-determine-an-assemblys-fully-qualified-name/

    ReplyDelete
  6. At Coepd (Center of Excellence for Professional Development) we practice Object-Oriented Programming concepts and mentor .Net Platform, C#.NET, ADO.NET which helps the attendees to build database-driven Web applications and Web Sites successfully. We also guide the attendees to develop web-based enterprise applications using ASP.NET and Visual Studio which comforts in developing the Web Services using .Net framework in Service-oriented Architecture. The Internship Program Also covers Frontend design technologies HTML, HTML5, CSS, CSS3, XML, Bootstrap, JQuery, Angular JS, and AJAX. Our collaborative ecosystem comprising of Partnerships with Software Companies enables real time software development life cycle experience.


    http://www.coepd.com/DotnetTraining.html

    ReplyDelete