注册COM +对象不能在传统的ASP中找到 [英] Registered COM+ object cannot be found in classic asp

查看:120
本文介绍了注册COM +对象不能在传统的ASP中找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#创建一个dll在VS2008。它是使用.NET Framework 2.0编译。该项目是使用Visual C#/ Windows下的类库模板创建的。我不知道,但如果该事项我尝试使用结果DLL中经典的ASP和asp.net应用程序不是一个桌面应用程序。

这是从利用现有传统ASP的VBScript code和C#中重写它创造。我不是很有经验的创造的dll所以有很多还需要学习。我一直在寻找在创造这个DLL所有样的帮助网页。

这是我迄今所做的。

顶层类设置是这样的:

 使用System.Runtime.InteropServices;
使用的System.EnterpriseServices;
使用系统;
使用System.Text;
使用的System.Web;[大会:应用程序名称(WebFramework)]
[大会:ApplicationActivati​​on(Activati​​onOption.Server)
[大会:ApplicationAccessControl(假的,
           AccessChecksLevel = AccessChecksLevelOption.ApplicationComponent)命名空间WebFramework
{
    [GuidAttribute(AACB678E-2C54-450A-873D-​​77A5A15BA0E5)]
    公共类框架:ServicedComponent的
    {
        //布拉赫
    }
}

其他类项目是公开的,他们都从类继承框架。我并没有包括这些类的GuidAttribute指令,因为我不知道这是否是必要的或没有。我也需要他们接触,因为我会从我传统的ASP / asp.net应用程序中引用它们。

在我编我的code我复制了三个文件; Inter.Scripting.dll,WebFramework.dll和WebFramework.pdb到Web服务器

该网站的服务器是与IIS 7.5安装。

在Windows 2008 R2箱

在服务器上的命令提示符下,我跑了regsvcs程序,并安装了这个组件,并与出任何问题注册的DLL。该命令窗口是这样的:

<$p$p><$c$c>E:\\inetpub\\wwwroot\\web\\WebFramework>\"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319/regsvcs.exe\" /应用程序的名字:WebFramework /tlb:WebFramework.tlb WebFramework.dll微软(R).NET框架服务安装实用程序版本4.0.30319.17929版权所有(C)微软公司。版权所有。安装组件:
        大会:E:\\的Inetpub \\ wwwroot的\\网络\\ WebFramework \\ WebFramework.dll
        应用:WebFramework
        类型库:E:\\的Inetpub \\ wwwroot的\\网络\\ WebFramework \\ WebFramework.tlb

我查了组件服务应用程序,并有下COM +应用WebFramework对象。我也跑regedit并搜索WebFramework,它发现我的电脑下的应用程序\\ HKEY_CLASSES_ROOT \\ WebFramework ..

到目前为止,我觉得一切是正确的....是吗?

当我运行一个测试传统的ASP页面具有以下code,我得到的错误424 - 必需对象

 &LT; HTML和GT;
&LT; HEAD&GT;
    &LT;标题&GT;&LT; /标题&GT;
&LT; /头&GT;&LT;身体GT;
    &LT;脚本类型=文/ VBScript中&GT;
        在错误恢复下一页        昏暗WebFrame
        设置WebFrame =的Server.CreateObject(WebFramework.Framework)        的document.write(&LT;小时&gt;中)
        文件撰写(Err.Number的)
        的document.write( - )
        文件撰写(Err.Description它将)
        的document.write(&LT; BR&GT;&LT;小时&gt;中)    &LT; / SCRIPT&GT;
&LT; /身体GT;
&LT; / HTML&GT;

我在想什么?为什么不能在ASP页面查找DLL?

我忘了提一件事。在生成选项卡上的项目属性页中存在一个注册为COM Interop复选框。我曾尝试使用该选项编译选中和未选中它并没有区别。


解决方案

而专注您的COM组件是问题试着改变你的ASP code到有效的语法。


  

&LT; HTML和GT;
&LT; HEAD&GT;
    &LT;标题&GT;&LT; /标题&GT;
&LT; /头&GT;&LT;身体GT;


  
     

&LT;%
    这code将被处理服务器端
    在错误恢复下一页    昏暗WebFrame
    设置WebFrame =的Server.CreateObject(WebFramework.Framework)
    难道我们有一个错误?显示它。
    如果Err.Number的&LT;&GT; 0,则
      的Response.Write(&LT;小时&gt;中)
      的Response.Write(Err.Number的)
      回复于( - )
      的Response.Write(Err.Description它将)
      的Response.Write(&LT; BR&GT;&LT;小时&gt;中)
    万一
    %GT;


  
  

&LT; /身体GT;
&LT; / HTML&GT;



为什么找不到对象错误?

如上的code规定是无效的,为什么?


  1. &LT的使用;脚本类型=文/ VBScript中&GT; 标签(通常为 =服务器是需要使用&LT;脚本&GT; 标签的服务器端,但是当你的表明它是由ASP处理。在未来,尽管我会推荐一个错误。您使用&LT;%%&GT; 来区分服务器端处理


  2. 除非你初始化它在其他地方,也没有叫文件这样的ASP对象。如果我是猜我会说你试图向屏幕输出。要做到这一点使用内置的响应对象(服务器端请求是由的请求响应)。


我会说你的找不到对象是由ASP不理解什么文件是,因此提高了<所致code>找不到对象错误。



  

更新


  
  

看完后你的<一个href=\"http://stackoverflow.com/questions/23794453/registered-com-object-cannot-be-found-in-classic-asp#comment36626473_23794453\">comment我意识到,你的code的是间preTED客户端等等文件撰写不会导致找不到对象错误我觉得现在的问题是的Server.CreateObject ,因为这是与客户端服务器端语法的VBScript 不会明白的。


I created a dll in VS2008 using C#. It was compiled using .Net Framework 2.0. The project was created using the Class Library template under Visual C# / Windows. I don't know if that matters but I am trying to use the resulting dll in both classic asp and asp.net applications not on a desktop app.

This was created by taking existing classic asp vbscript code and rewriting it in C#. I am not very experienced with creating dlls so there is a lot of still need to learn. I have been searching the web for all kind of help in creating this dll.

Here is what I have done so far.

The top level class is set up like this:

using System.Runtime.InteropServices;
using System.EnterpriseServices;
using System;
using System.Text;
using System.Web;

[assembly: ApplicationName("WebFramework")]
[assembly: ApplicationActivation(ActivationOption.Server)]
[assembly: ApplicationAccessControl(false,
           AccessChecksLevel = AccessChecksLevelOption.ApplicationComponent)]

namespace WebFramework
{
    [GuidAttribute("AACB678E-2C54-450A-873D-77A5A15BA0E5")]
    public class Framework : ServicedComponent
    {
        //Blah
    }
}

The other classes in the project are public and they all inherit from class Framework. I did not include the GuidAttribute directive for those classes because I don't know if that is necessary or not. I do need them exposed because I will reference them from my classic asp / asp.net applications.

After I compiled my code I copied the three files; Inter.Scripting.dll, WebFramework.dll and WebFramework.pdb to the web server.

The web server is a Windows 2008 R2 box with IIS 7.5 installed.

In a command prompt on the server I ran the regsvcs program and it installed this assembly and registered the dll with out any problems. The command window looked like this:

E:\inetpub\wwwroot\web\WebFramework>"C:\Windows\Microsoft.NET\Framework\v4.0.30319/regsvcs.exe" /appname:WebFramework /tlb:WebFramework.tlb WebFramework.dll

Microsoft (R) .NET Framework Services Installation Utility Version 4.0.30319.17929 Copyright (C) Microsoft Corporation.  All rights reserved.

Installed Assembly:
        Assembly: E:\inetpub\wwwroot\web\WebFramework\WebFramework.dll
        Application: WebFramework
        TypeLib: E:\inetpub\wwwroot\web\WebFramework\WebFramework.tlb

I checked the the Component Services app and there was a WebFramework object under COM+ Applications. I also ran regedit and searched for "WebFramework" and it found my application under Computer\HKEY_CLASSES_ROOT\WebFramework..

So far I think everything is correct....or is it?

When I run a test classic asp page with the following code I get Error 424 - Object required.

<html>
<head>
    <title></title>
</head>

<body>
    <script type="text/vbscript">
        On Error Resume Next

        Dim WebFrame
        Set WebFrame = Server.CreateObject("WebFramework.Framework")

        Document.Write("<hr>")
        Document.Write(Err.Number)
        Document.Write(" - ")
        Document.Write(Err.Description)
        Document.Write("<br><hr>")

    </script>
</body>
</html>

What am I missing? Why can't the asp page find the dll?

[Edit] One other thing that I forgot to mention. In the Project Properties page on the Build tab there is a check box for Register for COM interop. I have tried compiling with this option checked and unchecked and it made no difference.

解决方案

Instead of concentrating on your COM component being the issue try changing your ASP code to valid syntax.

<html>
<head>
    <title></title>
</head>

<body>

    <%
    'This code will be processed server-side
    On Error Resume Next

    Dim WebFrame
    Set WebFrame = Server.CreateObject("WebFramework.Framework")
    'Do we have an error? Display it.
    If Err.Number <> 0 Then 
      Response.Write("<hr>")
      Response.Write(Err.Number)
      Response.Write(" - ")
      Response.Write(Err.Description)
      Response.Write("<br><hr>")
    End If
    %>

</body>
</html>


Why the Object Not Found Error?

As stated above your code wasn't valid, why?

  1. Use of <script type="text/vbscript"> tag (usually runat="server" is required to use <script> tags server side, but as you get an error that suggests it is being processed by ASP. In future though I would recommend you use <% and %> to distinguish server side processing.

  2. Unless you instantiate it somewhere else, there is no such ASP object called Document. If I was to guess I would say you are trying to output to screen. To do this use the inbuilt Response object (server side request are made up of Request and Response).

I would say your Object Not Found is caused by ASP not understanding what Document is and hence raises the Object Not Found error.


Update

After reading your comment I realised that your code was being interpreted client side and so the Document.Write would not cause an Object Not Found error I think now the problem is the Server.CreateObject because this is server side syntax with client side VBScript will not understand.

这篇关于注册COM +对象不能在传统的ASP中找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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