本文整理汇总了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