App_Code类无法正常工作 [英] App_Code class not working

查看:91
本文介绍了App_Code类无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助。


我在app_code文件夹中创建了一个vb文件。以下是代码:


进口Microsoft.VisualBasic

进口System.Net.Mail

公共类email_error


公共函数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>消息:其中/ B个;<峰; br>" &安培; str_Message& "<峰; br><峰; br>" _

& "< b> SQL字符串:< / b>< br>" &安培; str_SQL& "<峰; br><峰; br>" _

& "< b取代;一切:其中/ B个;<峰; br>" &安培; str_ExString& "<峰; br><峰; br>" _

& "<峰; br>< b取代;堆栈跟踪:其中/ B个:其中峰; br>" &安培; str_StackTrace


mail.Body = str_Error


Dim instance As New SmtpClient(" XXXXXX")

instance.Send(mail)


返回str_Error


结束函数

结束类
然后我这样调用这段代码:


Dim myEmail As new email_error

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

strSQL,ex.StackTrace.ToString,ex.ToString)


所有这一切都很好,除非具有此

代码的文件的文件夹是IIS中的应用程序。如果我删除它的应用程序它会工作

但其他一切都开始爆炸了。


我创建应用程序时得到的错误是:


描述:编译资源期间发生错误

为此请求提供服务。请查看以下具体的

错误详细信息并适当修改源代码。


编译器错误消息:BC30002:未定义类型''email_error''。


突出显示这一行:


Dim myEmail As new email_error


有没有人有想法?


提前致谢。

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.

推荐答案

你是说它没有'当app_code目录被标记为

IIS中的应用程序时工作?

-

Christopher A. Reed

牛很慢,但地球很耐心。


< ma ******** @ myrapidsys.com>在消息中写道

news:11 ********************* @ g47g2000cwa.googlegro ups.com ...
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...
需要帮助。

我在app_code文件夹中创建了一个vb文件。以下是代码:

进口Microsoft.VisualBasic
进口System.Net.Mail

公共类email_error

公共功能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 ="外部Web错误" &安培; str_Page

str_Error ="< b> Page:< / b>< br>" &安培; str_Page& "<峰; br><峰; br>" _
& "< B>消息:其中/ B个;<峰; br>" &安培; str_Message& "<峰; br><峰; br>" _
& "< b> SQL字符串:< / b>< br>" &安培; str_SQL& "<峰; br><峰; br>" _
& "< b取代;一切:其中/ B个;<峰; br>" &安培; str_ExString& "<峰; br><峰; br>" _
& "<峰; br>< b取代;堆栈跟踪:其中/ B个:其中峰; br>" &安培; str_StackTrace

mail.Body = str_Error

Dim instance As New SmtpClient(" XXXXXX")
instance.Send(mail)

返回str_Error

结束函数
结束类

然后我这样调用这段代码:

Dim myEmail As新的email_error

myEmail.Send_Error(Request.ServerVariables(" Path_I nfo"),ex.Message,
strSQL,ex.StackTrace.ToString,ex.ToString)
<除了具有此代码的文件是IIS中的应用程序的文件夹之外,所有这些都可以正常工作。如果我删除应用程序它可以工作
但其他一切都开始爆炸。

我创建应用程序时得到的错误是:

描述:在编译服务此请求所需的资源期间发生错误。请查看以下特定的
错误详细信息并适当修改源代码。

编译器错误消息:BC30002:未定义类型email_error。

突出显示这一行:

将我的电子邮件视为新的email_error

有没有人有任何想法?

提前致谢。
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.



不,当调用该类的代码为

in的文件夹被标记为应用程序时,它不起作用。
No, it doesnt work when the folder that the code calling the class is
in is marked as an application.


2006年2月18日22:16:30 -0800, ma *** *****@myrapidsys.com 写道:
On 18 Feb 2006 22:16:30 -0800, ma********@myrapidsys.com wrote:
需要帮助。



[snip]


我无法从您的代码中看出来,但似乎您可能会从您声明它的

范围内调用该类。


Otis Mukinfus
http://www.otismukinfus.com
http:// www.tomchilders.com


这篇关于App_Code类无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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