I am trying to call a method I have written in C# from VBScript.
I have followed just about all of the instructions I can find on the web and am still having problems.
Specifically I am getting
Error: ActiveX component can't create object
Code: 800A01AD
So far I have done the following:
ComVisible(true)
regasm /codebase
My VBScript looks like this:
set oObject = CreateObject("TTTTTT.FFFFF.CCCCCCCCC")
My C# code looks like this:
using System;
using System.IO;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace XXXXX.YYYYY
{
[ComVisible(true)]
[Guid("3EB62C37-79BC-44f7-AFBD-7B8113D1FD4F")]
[ProgId("TTTTTT.FFFFF.CCCCCCCCC")]
public class CCCCCCCCC
{
public void MyFunc()
{
//
}
}
}
Can anyone help?
Have you read this article: COM Interop Exposed
In the last page (3) of the article, there's a list:
ClassInterface(ClassInterfaceType.None)
"
attribute to prevent regasm/tlbexp
from creating an empty default
interface.I'm not sure if the GAC and ClassInterfaceType.None
are the missing pieces of your puzzle, you might want to give it a try. Good luck!
There isn't anything really wrong with your code and you followed the correct install procedure, by the sound of it. The error code you get however clearly indicates that the script interpreter has trouble locating or loading the assembly. The best way to troubleshoot this is with SysInternals' ProcMon utility.
I ran your code without trouble, these were the most relevant entries in the ProcMon log:
22 12:04:41.1795038 PM WScript.exe 55280 RegOpenKey HKCR\TTTTTT.FFFFF.CCCCCCCCC SUCCESS Desired Access: Read
26 12:04:41.1795682 PM WScript.exe 55280 RegOpenKey HKCR\TTTTTT.FFFFF.CCCCCCCCC\CLSID SUCCESS Desired Access: Read
29 12:04:41.1796996 PM WScript.exe 55280 RegQueryValue HKCR\TTTTTT.FFFFF.CCCCCCCCC\CLSID\(Default) SUCCESS Type: REG_SZ, Length: 78, Data: {3EB62C37-79BC-44F7-AFBD-7B8113D1FD4F}
34 12:04:41.1797653 PM WScript.exe 55280 RegOpenKey HKCR\CLSID\{3EB62C37-79BC-44F7-AFBD-7B8113D1FD4F} SUCCESS Desired Access: Read
62 12:04:41.1802539 PM WScript.exe 55280 RegOpenKey HKCR\CLSID\{3EB62C37-79BC-44F7-AFBD-7B8113D1FD4F}\InprocServer32 SUCCESS Desired Access: Read
71 12:04:41.1804181 PM WScript.exe 55280 RegQueryValue HKCR\CLSID\{3EB62C37-79BC-44F7-AFBD-7B8113D1FD4F}\InprocServer32\(Default) SUCCESS Type: REG_SZ, Length: 24, Data: mscoree.dll
824 12:04:41.2425662 PM WScript.exe 55280 RegQueryValue HKCR\CLSID\{3EB62C37-79BC-44F7-AFBD-7B8113D1FD4F}\InprocServer32\1.0.0.0\CodeBase SUCCESS Type: REG_SZ, Length: 124, Data: file:///c:/projects/ClassLibrary2/obj/Debug/ClassLibrary2.DLL
... Lots of .NET keys...
1239 12:04:41.2970169 PM WScript.exe 55280 CreateFile C:\projects\ClassLibrary2\obj\Debug\ClassLibrary2.dll SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With