Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

AssemblyName.CultureInfo Property

Gets or sets the culture supported by the assembly.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
'Declaration
Public Property CultureInfo As CultureInfo
'Usage
Dim instance As AssemblyName 
Dim value As CultureInfo 

value = instance.CultureInfo

instance.CultureInfo = value

Property Value

Type: System.Globalization.CultureInfo
A CultureInfo object representing the culture supported by the assembly.

The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the CultureInfo property is used to specify the culture, which is part of the assembly's display name.

Imports System
Imports Microsoft.VisualBasic
Imports System.Reflection
Imports System.Threading
Imports System.IO
Imports System.Globalization
Imports System.Reflection.Emit
Imports System.Configuration.Assemblies

Public Class AssemblyName_CodeBase

   Public Shared Sub MakeAssembly(myAssemblyName As AssemblyName, fileName As String)
      ' Get the assembly builder from the application domain associated with the current thread. 
      Dim myAssemblyBuilder As AssemblyBuilder = Thread.GetDomain().DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.RunAndSave)
      ' Create a dynamic module in the assembly. 
      Dim myModuleBuilder As ModuleBuilder = myAssemblyBuilder.DefineDynamicModule("MyModule", fileName)
      ' Create a type in the module. 
      Dim myTypeBuilder As TypeBuilder = myModuleBuilder.DefineType("MyType")
      ' Create a method called 'Main'. 
      Dim myMethodBuilder As MethodBuilder = myTypeBuilder.DefineMethod("Main", MethodAttributes.Public Or MethodAttributes.HideBySig Or MethodAttributes.Static, GetType(object), Nothing)
      ' Get the Intermediate Language generator for the method. 
      Dim myILGenerator As ILGenerator = myMethodBuilder.GetILGenerator()
      ' Use the utility method to generate the IL instructions that print a string to the console.
      myILGenerator.EmitWriteLine("Hello World!")
      ' Generate the 'ret' IL instruction.
      myILGenerator.Emit(OpCodes.Ret)
      ' End the creation of the type.
      myTypeBuilder.CreateType()
      ' Set the method with name 'Main' as the entry point in the assembly.
      myAssemblyBuilder.SetEntryPoint(myMethodBuilder)
      myAssemblyBuilder.Save(fileName)
   End Sub 'MakeAssembly


   Public Shared Sub Main()

      ' Create a dynamic assembly with name 'MyAssembly' and build version '1.0.0.2001'. 
      Dim myAssemblyName As New AssemblyName()
      ' Set the codebase to the physical directory were the assembly resides.
      myAssemblyName.CodeBase = Directory.GetCurrentDirectory()
      ' Set the culture information of the assembly to 'English-American'.
      myAssemblyName.CultureInfo = New CultureInfo("en-US")
      ' Set the hash algoritm to 'SHA1'.
      myAssemblyName.HashAlgorithm = AssemblyHashAlgorithm.SHA1
      myAssemblyName.Name = "MyAssembly"
      myAssemblyName.Version = New Version("1.0.0.2001")
      MakeAssembly(myAssemblyName, "MyAssembly.exe")

      ' Get all the assemblies currently loaded in the application domain. 
      Dim myAssemblies As [Assembly]() = Thread.GetDomain().GetAssemblies()

      ' Get the dynamic assembly named 'MyAssembly'.  
      Dim myAssembly As [Assembly] = Nothing 
      Dim i As Integer 
      For i = 0 To myAssemblies.Length - 1
         If [String].Compare(myAssemblies(i).GetName().Name, "MyAssembly") = 0 Then
            myAssembly = myAssemblies(i)
         End If 
      Next i ' Display the full assembly information to the console.
      If Not (myAssembly Is Nothing) Then
         Console.WriteLine(vbCrLf & "Displaying the full assembly name" & vbCrLf)
         Console.WriteLine(myAssembly.GetName().FullName)
      End If 
   End Sub  
End Class

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.