|
-
Jan 1st, 2004, 12:55 PM
#1
Thread Starter
Frenzied Member
Calling a class constructor from outside the application
I have an ASP.NET (VB.NET) application, which has a class called clsSendEmail within it. I use this class from within the application to send a test email. What I want to do is create a console application, which will run completely independent of the web application, but is able to call the SendEmail class that is located within the Web app. How can I call the constructor of the SendMail class from outside the ASP.NET Application???
Example
VB Code:
'My ASP.NET Application
Public Class clsSendMail
Public Sub New(ByVal strServerName As String, ByVal strDBName As String)
'Create a new instance of teh SendMail Class
Dim Mail As New SendMail(strServerName, strDBName)
End Sub
Private Class SendMail()
'misc variable declarations
Public Sub New(ByVal strServerName As String, ByVal strDBName As String, Optional ByVal blnTestEmail As Boolean = False, Optional ByVal strMailingID As String = "")
'Do my email processing here, based on the parameters passed.
End Sub
End Class
End Class
Here would be my console application that would be able to call the clsSendMail constructor
VB Code:
Public Class ConsoleSendMail
'What needs to be in this class to be able to call the
'clsSendMail class in the ASP.NET Application???
End Class
Last edited by Memnoch1207; Jan 1st, 2004 at 01:01 PM.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Jan 1st, 2004, 01:13 PM
#2
Member
You have me curious. If no one responds and you do figure it out please post your findings here.
-
Jan 1st, 2004, 01:23 PM
#3
PowerPoster
You are going to want to compile it as a seperate assembly, then insert it into the GAC (Global Assembly Cache). I think you will have to give permission to the asp.net app to use it after you do it. Then in your asp.net app, you are going to want to add a reference to the assembly, and work with it like any other external dll.
The console app will need a reference to the dll also.
I personally haven't done this, but it is well documented.
http://msdn.microsoft.com/library/de...emblycache.asp
-
Jan 1st, 2004, 01:23 PM
#4
Thread Starter
Frenzied Member
Here would be my assumption.
The web application compiles to a .dll file (named appName.dll)
I would then assume that within the console application, I would need to create an instance of this appName.dll, then call the clsSendMail constructor???
Does anyone know if this is correct???
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Jan 1st, 2004, 01:32 PM
#5
You should be able to browse and reference the dll created for the ASP.NET app. Then just access the class you need.
You could also use Late Binding and Reflection to get the class and use it as well but you would have to know the full path to the assembly that contains it and it would be slower than making a reference.
PS: Making a reference will copy the dll to the application folder of the console app too.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|