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:
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?
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.