Assembly.GetName Method (System.Reflection)

Switch View :
ScriptFree
.NET Framework Class Library for Silverlight
Assembly.GetName Method
This member can be used only by trusted applications. If you try to use this member in a partial-trust application, your code will throw a MethodAccessException exception. This member is security-critical, which restricts its use.
[SECURITY CRITICAL]

Gets an AssemblyName for this assembly.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
Syntax

Visual Basic (Declaration)
<SecurityCriticalAttribute> _
Public Overridable Function GetName As AssemblyName
C#
[SecurityCriticalAttribute]
public virtual AssemblyName GetName()

Return Value

Type: System.Reflection.AssemblyName
An AssemblyName for this assembly.
Version Information

Silverlight

Supported in: 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Community Content

Duckboy
Simple Name
If you just want to get the simple name (normally, but not necessarily, the same as the assembly file name without the .dll extension), you can do the following to avoid the overhead of creating an AssemblyName object:

var simpleName = assembly.FullName.Split(',') [0];

For example, to load an XML resource when you don't know the application's assembly name (or don't want to hard-code it in your source), get the executing application's assembly name first, as follows:

var resourceFileName = "example.xml";
var appName = Application.Current.GetType().Assembly.FullName.Split (',') [0]; // simple name is first part
var resourceInfo = Application.GetResourceStream (new Uri (appName + ";component/"
+ resourceFileName, UriKind.Relative));
var doc = XDocument.Load (resourceInfo.Stream);


Samuel Jack
Workaround
This code will get the assembly name for you in Silverlight:

var assemblyName = new AssemblyName(assembly.FullName);