469,364 Members | 2,332 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

App_Code class not working

Need help.

I create a vb file in my app_code folder. Here is the code:

Imports Microsoft.VisualBasic
Imports System.Net.Mail
Public Class email_error

Public Function Send_Error(ByVal str_Page As String, ByVal str_Message
As String, _
ByVal str_SQL As String, ByVal str_StackTrace As String, _
ByVal str_ExString As String) As String

Dim str_Error As String = ""
Dim str_eMail As String = "XXXXXXXXX"

Dim mail As New MailMessage(str_eMail, str_eMail)

mail.IsBodyHtml = True

mail.Subject = "Outside Web Error " & str_Page

str_Error = "<b>Page:</b><br>" & str_Page & "<br><br>" _
& "<b>Message:</b><br>" & str_Message & "<br><br>" _
& "<b>SQL String:</b><br>" & str_SQL & "<br><br>" _
& "<b>Everything:</b><br>" & str_ExString & "<br><br>" _
& "<br><b>StackTrace:</b>:<br>" & str_StackTrace

mail.Body = str_Error

Dim instance As New SmtpClient("XXXXXX")

instance.Send(mail)

Return str_Error

End Function
End Class
Then I call this code like this:

Dim myEmail As New email_error

myEmail.Send_Error(Request.ServerVariables("Path_I nfo"), ex.Message,
strSQL, ex.StackTrace.ToString, ex.ToString)

All of this works just fine UNLESS the folder that the file with this
code is an application in IIS. If I remove the application it works
but everything else starts blowing up.

The error I get when I have the application created is this:

Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'email_error' is not defined.

With this line highlighted:

Dim myEmail As New email_error

Does anyone have any ideas?

Thanks in advance.

Feb 19 '06 #1
10 5937
Are you saying that it doesn't work when the app_code directory is marked as
an application in IIS?
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

<ma********@myrapidsys.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Need help.

I create a vb file in my app_code folder. Here is the code:

Imports Microsoft.VisualBasic
Imports System.Net.Mail
Public Class email_error

Public Function Send_Error(ByVal str_Page As String, ByVal str_Message
As String, _
ByVal str_SQL As String, ByVal str_StackTrace As String, _
ByVal str_ExString As String) As String

Dim str_Error As String = ""
Dim str_eMail As String = "XXXXXXXXX"

Dim mail As New MailMessage(str_eMail, str_eMail)

mail.IsBodyHtml = True

mail.Subject = "Outside Web Error " & str_Page

str_Error = "<b>Page:</b><br>" & str_Page & "<br><br>" _
& "<b>Message:</b><br>" & str_Message & "<br><br>" _
& "<b>SQL String:</b><br>" & str_SQL & "<br><br>" _
& "<b>Everything:</b><br>" & str_ExString & "<br><br>" _
& "<br><b>StackTrace:</b>:<br>" & str_StackTrace

mail.Body = str_Error

Dim instance As New SmtpClient("XXXXXX")

instance.Send(mail)

Return str_Error

End Function
End Class
Then I call this code like this:

Dim myEmail As New email_error

myEmail.Send_Error(Request.ServerVariables("Path_I nfo"), ex.Message,
strSQL, ex.StackTrace.ToString, ex.ToString)

All of this works just fine UNLESS the folder that the file with this
code is an application in IIS. If I remove the application it works
but everything else starts blowing up.

The error I get when I have the application created is this:

Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'email_error' is not defined.

With this line highlighted:

Dim myEmail As New email_error

Does anyone have any ideas?

Thanks in advance.

Feb 19 '06 #2
No, it doesnt work when the folder that the code calling the class is
in is marked as an application.

Feb 19 '06 #3
On 18 Feb 2006 22:16:30 -0800, ma********@myrapidsys.com wrote:
Need help.

[snip]

I can't tell from your code, but it appears that you might be calling the class from out of the
scope where you declared it.

Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Feb 19 '06 #4
Well all the code works fine if i remove the application in IIS from
the folder holding my web code (i.e. Page in folder "web_pages" called
"test_email", if i remove the IIS application from "web_pages"
everything works great with calling the class in "App_Code", once I
re-apply the application I get the "Type 'email_error' is not defined."

Feb 19 '06 #5
The App_Code subdirectory shouldn't be marked as an application. It is
strictly dependent on the main website application.

If this isn't what is happening, then please elaborate further.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

<ma********@myrapidsys.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
No, it doesnt work when the folder that the code calling the class is
in is marked as an application.

Feb 21 '06 #6
the App_Code directory is not marked as an application, just the
directory with all my aspx files in it. And thats what is not working.
folder "web_pages" contains all my aspx files. Some of those files
are calling a class in the App_Code folder. Intellisense knows about
the class in the .vb file in the App_Code folder and the functions in
that class. So that all works, and building the website shows no
errors. But when I hit the web page I get the "Type is not defined"
error.

Feb 22 '06 #7
here is a test page i put up to display the error:

http://www.asr.co.pima.az.us/APIQ/error_handling.aspx

Feb 22 '06 #8
Are you using namespaces?
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

<ma********@myrapidsys.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
here is a test page i put up to display the error:

http://www.asr.co.pima.az.us/APIQ/error_handling.aspx

Feb 22 '06 #9
yes i am using them thru web.config

<namespaces>
<add namespace="System"/>
<add namespace="System.Configuration"/>
<add namespace="System.Web"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.Image"/>
<add namespace="System.Web.UI.HTMLControls"/>
<add namespace="System.Collections"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Math"/>
<add namespace="Microsoft.VisualBasic"/>
<add namespace="System.Configuration"/>
<add namespace="System.Data"/>
<add namespace="System.Data.SqlClient"/>
<add namespace="System.Net.Mail"/>
</namespaces>

Feb 22 '06 #10
I meant in the files in your App_Code subdirectory.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

<ma********@myrapidsys.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
yes i am using them thru web.config

<namespaces>
<add namespace="System"/>
<add namespace="System.Configuration"/>
<add namespace="System.Web"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.Image"/>
<add namespace="System.Web.UI.HTMLControls"/>
<add namespace="System.Collections"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Math"/>
<add namespace="Microsoft.VisualBasic"/>
<add namespace="System.Configuration"/>
<add namespace="System.Data"/>
<add namespace="System.Data.SqlClient"/>
<add namespace="System.Net.Mail"/>
</namespaces>

Feb 23 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by sck10 | last post: by
2 posts views Thread by pradeep_TP | last post: by
9 posts views Thread by rn5a | last post: by
1 post views Thread by netasp | last post: by
reply views Thread by TonyBushell | last post: by
Frinavale
1 post views Thread by Frinavale | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.