本文整理匯總了VB.NET中System.Reflection.Emit.ModuleBuilder.DefineResource方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET ModuleBuilder.DefineResource方法的具體用法?VB.NET ModuleBuilder.DefineResource怎麽用?VB.NET ModuleBuilder.DefineResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Reflection.Emit.ModuleBuilder
的用法示例。
在下文中一共展示了ModuleBuilder.DefineResource方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: CodeGenerator
' 導入命名空間
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Resources
Public Class CodeGenerator
Public Sub New()
' Get the current application domain for the current thread.
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
Dim myAssemblyName As New AssemblyName()
myAssemblyName.Name = "TempAssembly"
' Define 'TempAssembly' assembly in the current application domain.
Dim myAssemblyBuilder As AssemblyBuilder = currentDomain.DefineDynamicAssembly _
(myAssemblyName, AssemblyBuilderAccess.RunAndSave)
' Define 'TempModule' module in 'TempAssembly' assembly.
Dim myModuleBuilder As ModuleBuilder = myAssemblyBuilder.DefineDynamicModule _
("TempModule", "TempModule.netmodule", True)
' Define the managed embedded resource, 'MyResource' in 'TempModule'.
Dim myResourceWriter As IResourceWriter = myModuleBuilder.DefineResource _
("MyResource.resource", "Description")
' Add resources to the resource writer.
myResourceWriter.AddResource("String 1", "First String")
myResourceWriter.AddResource("String 2", "Second String")
myResourceWriter.AddResource("String 3", "Third String")
myAssemblyBuilder.Save("MyAssembly.dll")
End Sub
End Class
Public Class CallerClass
Public Shared Sub Main()
Dim myGenerator As New CodeGenerator()
Console.WriteLine("A resource named 'MyResource.resource' has been created and can be" + _
" viewed in the 'MyAssembly.dll'")
End Sub
End Class
示例2: CodeGenerator
' 導入命名空間
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Resources
Public Class CodeGenerator
Public Sub New()
' Get the current application domain for the current thread.
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
Dim myAssemblyName As New AssemblyName()
myAssemblyName.Name = "TempAssembly"
' Define 'TempAssembly' assembly in the current application domain.
Dim myAssemblyBuilder As AssemblyBuilder = currentDomain.DefineDynamicAssembly _
(myAssemblyName, AssemblyBuilderAccess.RunAndSave)
' Define 'TempModule' module in 'TempAssembly' assembly.
Dim myModuleBuilder As ModuleBuilder = myAssemblyBuilder.DefineDynamicModule _
("TempModule", "TempModule.netmodule", True)
' Define the managed embedded resource, 'MyResource' in 'TempModule'
' with the specified attribute.
Dim writer As IResourceWriter = myModuleBuilder.DefineResource _
("MyResource.resource", "Description", ResourceAttributes.Public)
' Add resources to the resource writer.
writer.AddResource("String 1", "First String")
writer.AddResource("String 2", "Second String")
writer.AddResource("String 3", "Third String")
myAssemblyBuilder.Save("MyAssembly.dll")
End Sub
End Class
Public Class CallerClass
Public Shared Sub Main()
Dim myGenerator As New CodeGenerator()
Console.WriteLine("A resource named 'MyResource.resource' has been created and can be " + _
"viewed in the 'MyAssembly.dll'")
End Sub
End Class