I'm trying to slowly bring development of one of our web applications
to .NET, so for the time being I want all additions to be written in
..NET. I figure we'll just create libraries for all new functionality
and slowly move the framework over to .NET and before you know it we'll
have a full .NET system.
I have read quite a few articles and they all have the same advice.
Create a library in VS & build it. Then run "regasm
c:\directory\dllfile.dll /tlb /codebase" and you should can then do a
Server.CreateObject in your ASP (or a CreateObject in vbscript).
So I tried it out, first I created a HelloWorld class just to test:
using System;
using System.Collections.Generic;
using System.Text;
namespace Photogami
{
public class HelloWorld
{
public String printHello()
{
return "HELLO";
}
}
}
And in the ASP used Server.CreateObject("Photogami.HelloWorld").
After a number of hours of failing, I finally a got regasm to tell me
that "Types registered successfully" -- ran the ASP page with
"Server.CreateObject("Photogami.HelloWorld")" and called the function
and Voila -- it said Hello. Still not sure what I did to get it to
finally register (was about 5 hours later).
So I went on to start my REAL coding and have had no luck registering
the library. Here's what I wrote (for testing purposes I dumbed it
down to the following):
using System;
using System.Collections.Generic;
using System.Text;
namespace Photogami
{
class Album
{
public String display()
{
return " ";
}
}
}
I set Register for COM interop in the Options and also set [assembly:
ComVisible(true)] in the Assembly info (don't know if they're
necessary, but...). I get a warning upon build that the dll does not
contain any types that can be un/registered for COM interop -- don't
get that on the HelloWorld (and yes, both those options are set in the
HelloWorld). Well, it builds ok, so I move it to the server and try a
"regasm photogami.dll" (no switches) and get "RegAsm : warning RA0000 :
No types were registered" -- don't get that with the HelloWorld either.
I then type "regasm photogami.dll /tlb /codebase" and get the warning
that the assembly is unsigned, but that the library was registered
successfully. Great, right? Well the ASP fails on the
Server.CreateObject. So I try "regasm photogami.dll /unregister" --
maybe something went wrong the first time, let's try it again... Well
that command tells me "RegAsm : warning RA0000 : No types were
un-registered". WHAT? So was it ever registered?
I have racked my brains on this for hours and hours trying everything I
can think of to make this thing work. Anyone have any idea what's
going on here?