使用C#.net DLL对象的经典ASP不支持此属性或方法 [英] Classic ASP using C# .net DLL Object doesn't support this property or method

查看:136
本文介绍了使用C#.net DLL对象的经典ASP不支持此属性或方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,这是我第一次为经典的ASP页面创建COM对象.

Hey all this is my first time creating a COM object for a classic asp page.

创建此COM DLL时遵循的过程是:

The process I followed when creating this COM DLL is this:

1)使用强名称工具(sn.exe)并将.snk文件放置在应用程序内. (sn -k myKey.snk)

1) Used the Strong Name Tool (sn.exe) and placed the .snk file within the app. (sn -k myKey.snk)

2)已添加:

[assembly: AssemblyKeyFile(@"myKey.snk")]
[assembly: ComVisible(true)]

到AssemblyInfo.cs.我确实在KeyFile上收到了一个警告,说:

to the AssemblyInfo.cs. I do get a warning on the KeyFile saying:

使用命令行选项'/keyfile'或适当的项目设置 而不是"AssemblyKeyFile"

Use command line option '/keyfile' or appropriate project settings instead of 'AssemblyKeyFile'

3)从管理员处运行以下命令:SDK命令提示符:

3) Ran the following from the Administrator: SDK Command Prompt:

tlbexp c:\\temp\\dll\\classicASPWSEnDecrypt.dll /out:c:\\temp\\dll\\classicASPWSEnDecrypt.tlb

regasm /tlb:c:\\temp\\dll\\classicASPWSEnDecrypt.tlb c:\\temp\\dll\\classicASPWSEnDecrypt.dll

gacutil /i c:\\temp\\dll\\classicASPWSEnDecrypt.dll

regasm c:\\temp\\dll\\classicASPWSEnDecrypt.dll /codebase

所有注册都很好,没有错误.

All registered just fine without errors.

在我的经典ASP页面中,我有:

In my classic ASP page i have:

<%
 Dim classicEnDecrypt
 Set classicEnDecrypt = Server.CreateObject("classicASPWSEnDecrypt.Class1")

 response.write(classicEnDecrypt.Encrypt("testing"))
%>

我发现 ProgID (使用OLEView)为Class1,如下所示:

I found that the ProgID (using OLEView) was Class1 as seen below:

我的C#代码(仅是一个片段)是这样:

And my C# code (just a snip) is this:

namespace classicASPWSEnDecrypt
{
  public class Class1
  {
      public string Encrypt(string PlainText)
      {
         [code here]
      }

      public string Decrypt(string EncryptedText)
      {
         [code here]
      }
  }
}

一旦我在本地计算机(IIS7/Windows 7 Enterprise)上运行ASP页面,就会出现此错误:

Once I run the ASP page on my local machine (IIS7/Windows 7 Enterprise) I get this error:

Microsoft VBScript运行时错误'800a01b6'

Microsoft VBScript runtime error '800a01b6'

对象不支持以下属性或方法:'Encrypt'

Object doesn't support this property or method: 'Encrypt'

/contactupdateWS.asp,第49行

/contactupdateWS.asp, line 49

不太确定为什么知道我知道我为什么没有加密功能?!

Not quite sure why it says I don't have Encrypt function when I know I do?!

我可能会缺少什么?

推荐答案

我已经在注释中提供了一些信息.

I already provided some information in comment.

我也觉得您不应该为此使用静态方法.看来com不支持静态方法.

I also feel that you should not have static method for this. It seems that com does not support static method.

http://msdn.microsoft.com/en-us/library/ms182198.aspx

还使用Server.CreateObject方法创建类的对象,因此很明显,您应该为此使用实例方法.

Also you are creating object of class by using Server.CreateObject method so it is quite obvious that you should have instance method for this.

public class Class1
  {
     public string Encrypt(string PlainText)
     {
     [code here]
     }

     public string Decrypt(string EncryptedText)
     {
     [code here]
     }
   }

希望获得帮助.

这篇关于使用C#.net DLL对象的经典ASP不支持此属性或方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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