Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 经典ASP使用的.NET程序集工作一次,然后抛出ObjectRefNotSetException_C#_.net_Com_Asp Classic_Exception Handling - Fatal编程技术网

C# 经典ASP使用的.NET程序集工作一次,然后抛出ObjectRefNotSetException

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

我在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\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
正在发生的事情是,在登录验证期间,程序集用于查找根据页面类型定义页面布局的用户类型。asp在首次登录后工作正常,返回的类型没有错误。但是,如果我注销或关闭页面并重新登录,ASP会在对象引用未设置为对象实例的com对象上抛出错误。就像GC在完成注册后没有拾取对象一样。该对象未设置为全局对象,仅在登录页面验证时使用。我在经典ASP页面中尝试过处理和不处理,得到了相同的结果

我不知道我需要做什么来解决这个问题。在过去的3天里,我一直在阅读关于这个主题的例子和主题,但我没有遇到任何其他人有同样的问题。任何想法、帮助或尝试的事情都将不胜感激

这是总成

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块?