如何从.vb创建文件.dll [英] how to create file .dll from .vb

查看:109
本文介绍了如何从.vb创建文件.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过这本书,名字是使用Visual Basic .NET进行面向对象的编程"
我不明白如何从文件hello.vb创建文件hello.dll,以及在2.1部分中的"C:\> vbc/t:library hello.vb"是什么意思:
"
例2-1包含我们的"Hello,world"组件的清单.它包含一个名为Hello的类以及一个名为Write的方法.将清单保存到名为hello.vb的文件中.本章的其余部分将使用此清单作为讨论的基础.

示例2-1 世界您好"组件

严格启用选项
导入系统命名空间Greeting
公开课您好
Public Sub Write(ByVal值作为字符串)
Console.WriteLine("Hello,{0}!",值)
结束子
结束类
结束命名空间


Visual Basic .NET命令行编译器是一个名为vbc.exe的程序,一旦安装了.NET Framework,该程序应位于您的路径中.本书中的所有示例均假定示例代码位于硬盘驱动器的根目录中.进行此假设是为了提高可读性.如果代码不在硬盘的根目录中,则需要指定已编译文件的标准路径名,或者从源代码所在的目录中进行编译.考虑到这一点,您应该能够将示例2-1编译为动态链接库(DLL),如下所示:

C:\> vbc/t:库hello.vb
/t:选项是target的缩写,可以是以下值之一:

exe
控制台应用程序.如果省略/t开关,则这是默认值.

winexe
Windows可执行文件.

图书馆
DLL.

模块
一个模块.此值类似于C ++中的.lib文件.它包含对象,但不是可执行文件.

默认情况下,编译器为输出文件提供与正在编译的文件相同的名称.此处将生成一个名为hello.dll的文件.

"
你能帮我吗?

I read the book, which name is "Object-Oriented Programming with Visual Basic .NET"
I don''t understand how to create file hello.dll from file hello.vb and what mean''s "C:\>vbc /t:library hello.vb" in the part 2.1:
"
Example 2-1 contains the listing for our "Hello, world" component. It contains a single class named Hello with a single method named Write. Save the listing to a file named hello.vb. The rest of the chapter will use this listing as a foundation of discussion.

Example 2-1. The "Hello, world" component

Option Strict On
Imports System Namespace Greeting
Public Class Hello
Public Sub Write(ByVal value As String)
Console.WriteLine("Hello, {0}!", value)
End Sub
End Class
End Namespace


The Visual Basic .NET command-line compiler is a program called vbc.exe that should be in your path once the .NET Framework is installed. All examples in this book assume that the example code exists in the root directory of your hard drive. This assumption is made to improve readability. If the code is not in your hard drive''s root directory, you need to specify a fully qualified pathname to the compiled file or compile from the directory where the source code is located. With this in mind, you should be able to compile Example 2-1 to a dynamic link library (DLL) as follows:

C:\>vbc /t:library hello.vb
The /t: option is short for target, which can be one of the following values:

exe
A console application. If the /t switch is omitted, this is the default value.

winexe
A Windows executable.

library
A DLL.

module
A module. This value is similar to a .lib file in C++. It contains objects but is not an executable.

As a default, the compiler gives the output file the same name as the file being compiled. Here, a file named hello.dll is produced.

"
can you help me???
thanks in advance!

推荐答案

这意味着您需要在命令行中输入"vbc ..."位.如果您已安装Visual Studio,则开始菜单中将存在一个快捷方式(Microsoft Visual Studio 20xx-> Visual Studio工具-> Visual Studio 20xx命令提示符),该快捷方式将打开所有设置为运行Visual Studio命令行工具(例如vbc,Visual Basic编译器)的路径
It means you need to enter the "vbc..." bit into a command line. If you''ve got visual studio installed, there''ll be a shortcut in your start menu (Microsoft Visual Studio 20xx -> Visual Studio Tools -> Visual Studio 20xx Command Prompt) that''ll open a command prompt with all the paths set up to run the visual studio command line tools (like vbc, the Visual Basic Compiler)


如果您使用的是Visual Studio,只需创建一个类库并使用build菜单选项进行构建.
If you are using Visual studio, just create a class library and build using the build menu option.


这篇关于如何从.vb创建文件.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆