1

I have a requirement where I have to use a base64 encoding on an image in classic ASP

so I created a very simple class project in C# project and trying to make it COM visible, I've read all the guides and various other questions on stackoverflow but I still can't get vbscript to create the Object

The assembly is marked as ComVisible and output is marked to register for COM interop, my source for the class:

namespace Crypto
{
    [ComVisible(true)]
    [Guid("ad491fe9-ade0-46a1-bae0-d407a987a9e9"),ClassInterface(ClassInterfaceType.None)]
    public class Base64
    {
        public Base64() {
            //default com exposable constructor
        }

        public string Base64Encode(string filePath) {

            if (!File.Exists(filePath)) return "";

            using (Image image = Image.FromFile(filePath))
            {
                using (MemoryStream m = new MemoryStream())
                {
                    image.Save(m, image.RawFormat);
                    byte[] imageBytes = m.ToArray();

                    // Convert byte[] to Base64 String
                    string base64String = Convert.ToBase64String(imageBytes);
                    return base64String;
                }
            }
        }
    }
}

After build, I register it as cominterop and put in in GAC anyway, using

regasm *<file path>* /codebase /tlb
gacutil -i *<file path>*

everything registers successfully

when I call from a test classic asp page

set obj = CreateObject("Crypto.Base64")

I get

Microsoft VBScript runtime error '800a01ad'

ActiveX component can't create object: 'Crypto.Base64'

I have worked with ComInterop about 7-8 years ago in .Net 2.0, everything worked smoothly, I can't understand whats wrong in this case

On my dev machine, it's windows 10 pro 64-bit, target compilation is 4.6.2 Framework

Danish
  • 741
  • 4
  • 17
  • 31
  • 1
    This should help - [Error ASP 0177: 8007007e Server.CreateObject fails for COM DLL](//stackoverflow.com/a/35985827) *(specifically - "How to register COM DLL with Windows" section)*. – user692942 Apr 07 '17 at 07:37
  • Possible duplicate of [Error ASP 0177: 8007007e Server.CreateObject fails for COM DLL](http://stackoverflow.com/questions/35976543/error-asp-0177-8007007e-server-createobject-fails-for-com-dll) – user692942 Apr 11 '17 at 14:13

1 Answers1

0

Thanks to @Lankymart for pointing me in the right direction

Even though the COM exposable .NET assembly was compiled for both 32-bit / 64-bit 32-bit Applications still need to be enabled in the App Pool advanced settings to get it to work

enter image description here

Danish
  • 741
  • 4
  • 17
  • 31