Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing a .NET Assembly from classic ASP

I have been trying to access a .NET Assembly that I have created in classic ASP using

dim foo
set foo = Server.CreateObject("TestAssembly.MyClass")

The problem is I'm getting an error:

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/test.asp, line 4

Invalid class string

I have registered the assembly (TestAssembly.dll) using gacutil and regasm as instructed in the article: Replacing Old Classic ASP COM Components with .NET Assemblies which I referenced from another question. It supplies two methods in which to install the assembly and I have tried both, but to no avail.

Getting this working would be great because it would allow me to gradually migrate a classic ASP site to .NET

like image 971
Simon Hartcher Avatar asked Feb 06 '09 12:02

Simon Hartcher


2 Answers

Another thing to check: make sure your .Net assembly is set to be COM Visible.

like image 168
brendan Avatar answered Oct 13 '22 11:10

brendan


Check in the registry here: *HKLM\SOFTWARE\Classes* and see if the namespace.class is there (e.g. "TestAssembly.MyClass") and that it has a key called "CLSID" with a valid ID.

If the registry entry isn't there then make sure that Project > Properties > Assembly Information has "Make assembly COM-Visible", then recompile. Once compiled, run regasm (if you're on a 64bit machine they you will have to explicitly reference the 64bit version of regasm - c:\Windows\microsoft.net\framework64\v4.0.30319\regasm) with:

regasm /codebase /tlb TestAssembly.dll
like image 3
icepicker Avatar answered Oct 13 '22 12:10

icepicker