I have the following sample code for a class library. after compiling I get no errors and everything seems fine but once I try to use it I get Error: Activex component can't create object: 'K32HardLinkWrap.Class1'
Imports System.Runtime.InteropServices
Public Class Class1
<DllImport("Kernel32.dll", CharSet:=CharSet.Unicode)>
Private Shared Function CreateHardLink(ByVal lpFileName As String, ByVal lpExistingFileName
As String, ByVal lpSecurityAttributes As IntPtr) As Boolean
End Function
Public Shared Function CreateHardLink_Api(ByVal lpFileName As String, ByVal lpExistingFileName As String, ByVal lpSecurityAttributes As IntPtr) As Boolean
CreateHardLink_Api = CreateHardLink(lpFileName, lpExistingFileName, lpSecurityAttributes)
End Function
End Class
Here is when I get Error: (This is a VB script File)
Set objAPI = CreateObject("K32HardLinkWrap.Class1")
I have tried many things I found searching SE but none of them works for me so I suppose I have something really wrong in the code and not in the registration process or while building the dll.
Things I tried:
using both regsvr32 from system32 and syswow64
using both cscript from system32 and syswow64
Using regasm both 32 and 64 versions
Register For COM Interop
Made Assembly COM VISIBLE.
I am not moving the dll file to system32 I am keeeping it in same dir as script in case this makes a difference, since I dont want to pollute my system directory with test dlls.
* UPDATE * This was just me being dumb and not correctly specifying the correct cscript (32) to run. Now I still have another problem Apparently I am not exposing CreateHardLink_Api correctly since i get a Object doesn't support this property or method" error.