2

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

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

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

2) Added:

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

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

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

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.

In my classic ASP page i have:

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

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

I found that the ProgID (using OLEView) was Class1 as seen below: enter image description here

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]
      }
  }
}

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

Microsoft VBScript runtime error '800a01b6'

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

/contactupdateWS.asp, line 49

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

What could I be missing?

StealthRT
  • 10,108
  • 40
  • 183
  • 342

1 Answers1

3

I already provided some information in comment.

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

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]
     }
   }

Hope this help.

dotnetstep
  • 17,065
  • 5
  • 54
  • 72
  • I have updated my OP to show the changes I have made. I still get the same error, however. – StealthRT Jun 20 '14 at 15:24
  • did you un-register first old assignment ? To test I simply created class library with comvisible(true) in AssemblyInfo.cs and use regasm. However when I try to add new method I have to uninstall with regasm and re-register. If still have issue try to change assemblyname. – dotnetstep Jun 20 '14 at 15:31
  • What you tried ? Let me know. I still prefer completely take New Class Library and test with that. It will definitely work. – dotnetstep Jun 20 '14 at 16:33