I created a dll in VS2008 using C#. It was compiled using .Net Framework 2.0. The project was created using the Class Library template under Visual C# / Windows. I don't know if that matters but I am trying to use the resulting dll in both classic asp and asp.net applications not on a desktop app.
This was created by taking existing classic asp vbscript code and rewriting it in C#. I am not very experienced with creating dlls so there is a lot of still need to learn. I have been searching the web for all kind of help in creating this dll.
Here is what I have done so far.
The top level class is set up like this:
using System.Runtime.InteropServices;
using System.EnterpriseServices;
using System;
using System.Text;
using System.Web;
[assembly: ApplicationName("WebFramework")]
[assembly: ApplicationActivation(ActivationOption.Server)]
[assembly: ApplicationAccessControl(false,
AccessChecksLevel = AccessChecksLevelOption.ApplicationComponent)]
namespace WebFramework
{
[GuidAttribute("AACB678E-2C54-450A-873D-77A5A15BA0E5")]
public class Framework : ServicedComponent
{
//Blah
}
}
The other classes in the project are public and they all inherit from class Framework. I did not include the GuidAttribute directive for those classes because I don't know if that is necessary or not. I do need them exposed because I will reference them from my classic asp / asp.net applications.
After I compiled my code I copied the three files; Inter.Scripting.dll, WebFramework.dll and WebFramework.pdb to the web server.
The web server is a Windows 2008 R2 box with IIS 7.5 installed.
In a command prompt on the server I ran the regsvcs program and it installed this assembly and registered the dll with out any problems. The command window looked like this:
E:\inetpub\wwwroot\web\WebFramework>"C:\Windows\Microsoft.NET\Framework\v4.0.30319/regsvcs.exe" /appname:WebFramework /tlb:WebFramework.tlb WebFramework.dll
Microsoft (R) .NET Framework Services Installation Utility Version 4.0.30319.17929 Copyright (C) Microsoft Corporation. All rights reserved.
Installed Assembly:
Assembly: E:\inetpub\wwwroot\web\WebFramework\WebFramework.dll
Application: WebFramework
TypeLib: E:\inetpub\wwwroot\web\WebFramework\WebFramework.tlb
I checked the the Component Services app and there was a WebFramework object under COM+ Applications. I also ran regedit and searched for "WebFramework" and it found my application under Computer\HKEY_CLASSES_ROOT\WebFramework..
So far I think everything is correct....or is it?
When I run a test classic asp page with the following code I get Error 424 - Object required.
<html>
<head>
<title></title>
</head>
<body>
<script type="text/vbscript">
On Error Resume Next
Dim WebFrame
Set WebFrame = Server.CreateObject("WebFramework.Framework")
Document.Write("<hr>")
Document.Write(Err.Number)
Document.Write(" - ")
Document.Write(Err.Description)
Document.Write("<br><hr>")
</script>
</body>
</html>
What am I missing? Why can't the asp page find the dll?
[Edit] One other thing that I forgot to mention. In the Project Properties page on the Build tab there is a check box for Register for COM interop. I have tried compiling with this option checked and unchecked and it made no difference.