I have created a windows forms application called ODTuner. It was written in vb.net using VS2010. I am attempting to get an object reference to a running instance of this application from a plugin I'm writing for another application. However, when the assignment is made:
Dim odt as Object
odt = GetObject(, "ODTuner.Application")
I get an error saying, "Object variable or With block variable not set" If I execute it from a VBScript using CreateObject, I get an error saying, "ActiveX Component can not create object."
Now, I believe I have the appropriate attributes set in ODTuner as follows:
<comvisibleattribute(true),> Guid("896746B9-ECEE-4EB3-9DB7-BAC2D318D07C"), _
ProgId("ODTuner.Application"), _
ClassInterface(ClassInterfaceType.None)> _
Public Class ODTuner
At first, I thought it must not be getting registered properly, even though the ComVisibleAttribute is set to true, and "Make Assembly COM Visible" is checked in AssemblyInformation. When logged in as an administrator, I searched the registry and did find it registered there with the correct GUID under Computer\HKEY_CLASSES_ROOT\. Oh, I have also tried registering it manually using regasm.
So, my question is, if it does appear in the registry, why am I getting an error. I did find a post somewhere that said that you cannot use GetObject to get an object reference to a class created in Visual Basic (it did not mention .NET specifically). This does not make sense to me, but if it is true, how do you get an object reference to a class created in VB?
I have the feeling that I changed something manually in VS that it handles automatically, and corrupted something, but I have searched and searched and cannot figure out why this does not work.
Any help would be appreciated. I have been stuck on this too long already.
Update: The "Object variable or With block variable not set" error was caused by a different problem. The correct error message is "Cannot create ActiveX component."
odt = CreateObject("ODTuner.Application"
OR
odt = GetObject(, "ODTuner.Application")
both give this error.