C# 经典ASP使用的.NET程序集工作一次,然后抛出ObjectRefNotSetException
我在VS2010中创建了一个.NET程序集,供经典ASP中的供应商web应用程序使用C# 经典ASP使用的.NET程序集工作一次,然后抛出ObjectRefNotSetException,c#,.net,com,asp-classic,exception-handling,C#,.net,Com,Asp Classic,Exception Handling,我在VS2010中创建了一个.NET程序集,供经典ASP中的供应商web应用程序使用 该程序集是为.NET 3.5(位于开发人员计算机上)编译的 我有一台运行windows XP Pro和IIS 5.1的本地IIS开发pc 我已将程序集设置为“使Com可见” 生成设置为“注册COM互操作” 在开发机器上,我使用regasm mydll.dll/codebase注册dll 在开发计算机上,我授予IUSR和IWAM用户帐户对注册表的读取权限HKEY\U USERS\S-1-5-20\Softwar
- 该程序集是为.NET 3.5(位于开发人员计算机上)编译的
- 我有一台运行windows XP Pro和IIS 5.1的本地IIS开发pc
- 我已将程序集设置为“使Com可见”
- 生成设置为“注册COM互操作”
- 在开发机器上,我使用regasm mydll.dll/codebase注册dll
- 在开发计算机上,我授予IUSR和IWAM用户帐户对注册表的读取权限
HKEY\U USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
namespace rd_custom
{
[ClassInterfaceAttribute(ClassInterfaceType.AutoDual), EventTrackingEnabled]
public class rd_Custom
{
private rd_Logger rdLog;
private XmlDocument DADoc;
public String getRequesterType(String reqId, String dbProf)
{
//"Logic is Here to do user Lookups"
rd_sqlCon rdCon = new rd_sqlCon();
rdCon.rdLog = rdLog; // This is Disposed and Set to null later as well
rdCon.LoadSqlConfig(dbProf, "requester_type");
String[] parms = new String[1];
parms[0] = "requester_id|" + reqId;
DataTable dt = rdCon.builDataTable(parms);
rdCon.Dispose(); //*Answer
rdCon = null; //Previously was setting to null
return strRequesterType;
}
}
}
这是引用COM的经典ASP
Dim ls_requester_type
Dim rdCustomObj
Set rdCustomObj = Server.CreateObject("rd_custom.rd_custom")
*Err*ls_requester_type = rdCustomObj.getRequesterType(CStr(l_l_requester_id), CStr(l_s_db_profile))*
If ls_requester_type <> "ERROR" Then
Session("RequesterType") = ls_requester_type
End If
Set rdCustomObj = nothing
Dim ls\u请求者\u类型
Dim rdCustomObj
设置rdCustomObj=Server.CreateObject(“rd_custom.rd_custom”)
*Err*ls_requester_type=rdCustomObj.getRequesterType(CStr(l_l_requester_id),CStr(l_s_db_profile))*
如果ls_请求者_键入“错误”,则
会话(“请求者类型”)=ls\u请求者类型
如果结束
设置rdCustomObj=nothing
您可以标记代码行中的“ASP在对象引用未设置为对象实例的my com对象上引发错误”吗?我在引发对象错误的行的开头添加了Err。如果加载com对象时出现问题,我会在CreateObject调用时将其执行为失败。您是否验证了在调用失败时定义了l_l_请求者id和l_s_db_配置文件变量?@user957902是的,我已验证l_l_请求者id和l_s_db_配置文件是否包含值。如果他们不这样做,网站的许多其他部分都会出现问题。这两个都是为每个页面在本地设置的会话变量。我的直觉是,execption被抛出到getRequesterType方法中,在.Net代码中。在方法的实现中是否有try-catch块?