如何运行DLL? [英] How to run DLL?

查看:52
本文介绍了如何运行DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MS Visual Studio Beta1中创建了一个Windows类库项目。当我尝试运行该项目时,我得到了一个弹出窗口:


无法直接启动输出类型为类库的项目。 br />
为了调试这个项目,请转到Project Properties中的Debugging选项卡

设置,并将Start Action设置为Start External

程序或起始URL。


这是否意味着DLL只能通过一些其他EXE调试或启动,这两个EXE是否需要调用DLL中的特定函数? />

我确实有另一个项目只有一个用于调用DLL的表单。它有两个

按钮:一个用于实例化对象(DLL),另一个用于调用方法

。整个代码是:


选项明确关闭


公共类Form1


私人mailobj As TestSaveEmail.Form1


Private Sub instantiate_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理实例化。点击

mailobj = New TestSaveEmail.Form1

mailobj.SaveEmail()

End Sub

结束班级


上面代码中的错误消息是

''SaveEmail''不是''TestSaveEmail.Form1''的成员。


SaveEmail是我试图调用的DLL。其中的函数是

没有参数的SaveMessage()。如何使其成为上述成员?


谢谢,

Brett

解决方案
>这是否意味着DLL只能通过其他EXE

调试或启动

调用DLL中的特定函数?


是的。

SaveEmail是我试图打电话的DLL。其中的函数是没有参数的SaveMessage()。如何使其成为上述成员?




选项明确关闭


公共类Form1

私有mailobj作为SaveEmail


私有Sub instantiate_Click(ByVal发送者As System.Object,ByVal e As

System.EventArgs)处理instantiate.Click

mailobj =新的SaveEmail

mailobj.SaveMessage()

结束子

结束班


-


Raymond Lewallen
http://rlewallen.blogspot.com


这给出:


类型预期。


似乎并不知道SaveEmail是一个DLL。可能有什么问题?


Brett


Raymond Lewallen写道:

这是否意味着DLL只能通过其他EXE调试或启动


调用DLL中的特定函数?



是的。

SaveEmail是我试图调用的DLL。其中的函数是没有参数的SaveMessage()。如何使其成为上述成员?



选项明确关闭

公共类Form1
私人mailobj作为SaveEmail
<私有Sub instantiate_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理instantiate.Click
mailobj = New SaveEmail
mailobj.SaveMessage()
结束Sub
结束课程





http://rlewallen.blogspot.com



对不起,我以前没有回答过这个问题。 SaveEmail.dll

需要添加到项目的引用列表中。你的

类名是什么包含SaveMessage函数?它期望的类型

是SaveEmail.dll中类的名称。请参阅以下代码:


选项显式关闭


公共类Form1

私人mailobj为SaveEmail.ClassName' '包含

SaveMessage函数的DLL.Class的名称

Private Sub instantiate_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理实例化。点击

mailobj =新的SaveEmail.ClassName''DLL.Class的名称包含

SaveMessage函数

mailobj.SaveMessage()

结束次级

结束班级


-


Raymond Lewallen


" Brett" <峰; br *** @ discussions.microsoft.com>在留言中写道

新闻:1F ********************************** @ microsof t.com ...

这给出了:

预期的类型。

似乎并不知道SaveEmail是一个DLL。可能有什么问题?

Brett



I''ve created a windows class library project in MS Visual Studio Beta1. When
I try to run the project, I get a popup with this:

A project with an Output Type of Class Library cannot be started directly.
In order to debug this project, go to the Debugging tab under Configuration
Settings in Project Properties, and set the Start Action to Start External
Program or Start URL.

Does this mean DLLs can only be debugged or started via some other EXE that
calls a particular function in the DLL?

I do have another project with only a form for calling the DLL. It has two
buttons: One to instantiate the object (DLL) and another to invoke a method
in it. The entire code is:

Option Explicit Off

Public Class Form1

Private mailobj As TestSaveEmail.Form1

Private Sub instantiate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles instantiate.Click
mailobj = New TestSaveEmail.Form1
mailobj.SaveEmail()
End Sub
End Class

The error message in the above code is
''SaveEmail'' is not a member of ''TestSaveEmail.Form1''.

SaveEmail is the DLL I''m trying to call. The function within it is
SaveMessage() with no parameters. How do I make it a member to the above?

Thanks,
Brett

解决方案

> Does this mean DLLs can only be debugged or started via some other EXE
that

calls a particular function in the DLL?
Yes.
SaveEmail is the DLL I''m trying to call. The function within it is
SaveMessage() with no parameters. How do I make it a member to the above?



Option Explicit Off

Public Class Form1
Private mailobj As SaveEmail

Private Sub instantiate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles instantiate.Click
mailobj = New SaveEmail
mailobj.SaveMessage()
End Sub
End Class

--

Raymond Lewallen
http://rlewallen.blogspot.com


This gives:

Type expected.

It doesn''t seem to know that SaveEmail is a DLL. What might be wrong?

Brett

"Raymond Lewallen" wrote:

Does this mean DLLs can only be debugged or started via some other EXE


that

calls a particular function in the DLL?



Yes.

SaveEmail is the DLL I''m trying to call. The function within it is
SaveMessage() with no parameters. How do I make it a member to the above?



Option Explicit Off

Public Class Form1
Private mailobj As SaveEmail

Private Sub instantiate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles instantiate.Click
mailobj = New SaveEmail
mailobj.SaveMessage()
End Sub
End Class

--

Raymond Lewallen
http://rlewallen.blogspot.com



I''m sorry, I wasn''t thinking when I answered previously. SaveEmail.dll
needs to be added to the list of references to your project. What is your
class name that contains the SaveMessage function? The Type it is expecting
is the name of the class in SaveEmail.dll. See the code below:

Option Explicit Off

Public Class Form1
Private mailobj As SaveEmail.ClassName '' Name of DLL.Class that contains
SaveMessage function

Private Sub instantiate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles instantiate.Click
mailobj = New SaveEmail.ClassName '' Name of DLL.Class that contains
SaveMessage function
mailobj.SaveMessage()
End Sub
End Class

--

Raymond Lewallen

"Brett" <Br***@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...

This gives:

Type expected.

It doesn''t seem to know that SaveEmail is a DLL. What might be wrong?

Brett



这篇关于如何运行DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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