How to run DLL?

G

Guest

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
 
R

Raymond Lewallen

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
 
G

Guest

This gives:

Type expected.

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

Brett
 
R

Raymond Lewallen

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
 
G

Guest

Thanks. I seem to have made some progress and was able to complete the
build. However, when I click the instantiate button, I get this error
message:

Cannot create ActiveX component.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Exception: Cannot create ActiveX component.

What exactly does the above mean?

The code now looks like:

Option Explicit Off

Public Class Form1
Private mailobj As OutlookSaveEmail.SaveOutlookMessage

Private Outlookobj As TestOutlookSaveEmail.Form1

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

Thanks,
Brett
 
R

Raymond Lewallen

The error is not being thrown from the code you have posted here, but
actually from the OutlookSaveEmail.Dll you wrote, which probably creates
instances of Outlook via something like
Server.CreateObject("Outlook.Application"). That is where the error is
being thrown, trying to create an instance of the outlook process. I would
google 'System.Exception: Cannot create ActiveX component Outlook' and
you'll find may hits of people with the same issues and how they solved
them.
 
G

Guest

I did the search on that term. However, nothing seemed to work. One
suggestion was to use System.Web.Mail but does that reference Outlook?

Another was to use server.createobject() rather than only createobject().
Is server declared only as an object or something different?

One other thing was the web.config file and to be sure it has impersonate
user set to true. The one I have in the Windows folder does. There are a
few more in the program files folder. Which should I be checking?

Thanks,
Brett
 
R

Richard Myers

Your Public Class Form1
does not inherit from System.Windows.Forms.Form and then above you go to talk about web config
files?

Is this a winform or webform application?

Richard
 
R

Richard Myers

Server.CreateObject("Outlook.Application"). is for automation. If all you want to do is send an
email then System.Web.Mail is the way to go. It doesn't reference Outllook at all. Outlook uses some
of the same component as System.Web.Mail under the hood but Outlook is just a mail client that you
can bypass.

Sounds to me like a permissions problem. Maybe you dont have access to the Active Outllok server
object becuase your running from the web and your application is sandbox in non trusted code zone.
Or perhaps your deploying to a webserver that does not have outlook client installed.

Either way i think you are using the wrong tool for the job..try System.Web.Mail...its a very
simple namespace.

hth
Richard
 
G

Guest

The app with the form is working fine. The issue now is the ActiveX error
thrown from the DLL.

How can I tell if this is a win or webform?

The problem is most likely with permissions but I'm unsure where this
setting is.

Brett
 
R

Richard Myers

O.k a winform is windows form and a webform is a webpage.
Webpages have an .aspx extension and require a browser to view them.

I misread your previous post you were saying that someone else had told to check the web.config file
so they obviously thought you were using the web as well.
So to be clear you have a Winforms application calling a SameMail dll and you are trying to save a
message to an outlook folder and you are encountering an error that is causing an unhandled
exception to be thrown when trying to create your activex .dll

So first up have you added a reference into your savemail .dll for Outlook ActiveX

Microsoft Outlook 10.0 Object Library

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top