VB 6.0 debugging breakpoint doesn't hit - vbscript

I have a VB 6.0 Project having Class (cls) files. When I start (Debug) my project, and try to execute following statement in Classic ASP page,
Set objMyObject = Server.CreateObject("ProjName.ClassName")
No breakpoint is hit and following error occurs.
Microsoft VBScript runtime error '800a01ad' ActiveX component can't
create object
While if I use the same statement in another VB Project (test project) then breakpoint hits with no error.
Can anyone help ?

Well you are trying to create an instance of a COM object with the name 'ProjName.ClassName' - which is unlikely to be a real COM object.
Either your COM class needs to be one that has been registered in Windows, or it needs to be a class defined within your VB project.
The example in MSDN is:
Sub CreateADODB()
Dim adoApp As Object
adoApp = CreateObject("ADODB.Connection")
End Sub
Where ADODB.Connection is a COM class that has been previously registered in Windows. The code you have provided above is trying to instantiate a non existant class (unless it is already within the same VB project).
You say that the other project this works, then I will hazard a guess that the test project has a class called ClassName.
Ok -Updated. The error code is not 'DLL Missing' - It is likely to be some reason why the COM object could not be instantiated. The following Microsoft support page suggests some reasons and ways of tracking down the problem. Its likely to be some sort of missing dependency to the DLL.
http://support.microsoft.com/kb/194801

Related

VB6 project issue which applying DAO3.6 library

I have an VB6 application.
When trying to Start it prompts an error ActiveX component can't create object
The program is failed in below line
Set GCIWCon = CreateObject("Dbsecurity.database")
I have checked that DAO3.6 library is existed and below line can be executed
CreateObject ("Excel.Sheet")
Thus, I assumed that DAO3.6 is working properly, but the object "Dbsecurity.database" is not found.
I do have a rough idea about the DAO library but I have no idea what is missing in order to make the issued line work.
Can anyone suggest what the object "Dbsecurity.database" can be and how to include it in the VBA?
Thanks

Trying to debug from C# into VB6 yields TYPE_E_CANTLOADLIBRARY?

I have a VB6 DLL being accessed from some C# code.
Using the compiled & registered VB6 DLL there is no problem. But when I load the VB6 source into the VB6 IDE and run the project, the next run of the C# code will fail with the error below.
Stopping the running DLL in the VB6 IDE will again allow the C# program to work from the compiled DLL.
The VB6 DLL is compiled with binary compatibility.
The error message I receive in C# is:
An unhandled exception of type 'System.InvalidCastException' occurred
in appname.exe
Additional information:
Unable to cast COM object of type 'dllname.classnameClass' to
interface type 'dllname._classname'.
This operation failed because the QueryInterface call on the COM
component for the interface with IID
'{D8AB6D65-F5E7-4B9C-A039-67DDC630E5F7}' failed due to the following
error:
Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A
(TYPE_E_CANTLOADLIBRARY)).
Specifically this error occurs when the C# code tries to access any part of the interop object which actually comes from the underlying COM object. But accessing .NET Object-derived things like .ToString() work fine on that object.
Why am I getting this error?
Furthermore:
If I compile the C# code when the VB6 code is NOT running, it builds fine. But compiling when the VB6 code IS running, then I get an error:
BC30002 dllname.classname is not defined.
Thanks
Maybe someone else will have a deeper understanding, but this is what I eventually figured out:
Running either Visual Studio (.NET) or Visual Basic 6 as ADMIN while debugging in this scenario would cause the error. Running BOTH as WITHOUT ADMIN rights then it would work.
The quandary is that admin rights are needed for certain build operations (specifically, registering COM DLLs automatically). So that was the pitfall; ultimately I had to repeatedly switch between admin/non-admin settings for both tools in order to code-test-modify...
Note - when I've debugged in a different scenario where the program is a VB6 EXE debugging into C# code, this was never a problem. Everything could run in as admin no problem.

compile error: user-defined type not defined

There is compile error 'user-defined type not defined' I get in VB6 when I was tried to compile this code. Can anybody tell me what I need to do to solve this error? Following is the line for which I got the error:
Public Conn As ADODB.Connection
Public rs As ADODB.Recordset
You need to add the reference to the ADO type library:
Open your project.
Click the Project menu item, then select References...
From Available References, check the box next to Microsoft ActiveX Data Objects n.n Library, where n.n is one of the following:
6.1 - if you want your application to run only on Windows 7 or later
2.8 - if you want your application to run on Windows XP or later
Click OK.
You may also want to look at Referencing the ADO Libraries In a Visual Basic 6 Application from the ADO Programmer's Guide.

COMVisible class in VS 2010 assembly still not visible through com

I created a VS 2010 class library. Marked the assembly for Com Visibility. Signed the assembly with a strong key. Created my class, have my entry point method available.
The library works fine from a test project in C#.
I regasm the class library to gac, via:
c:\windows\microsoft.net\framework\v4.0.30319\regasm testdll.dll /tlb: testdll.tlb /codebase
Include the tlb file as a reference in my VB6 project. I find it through resources 'browse' so its there.
When i try to instantiate the class... its empty. the public method that should be available via the public class doesn't show.
Dim objTest as testdll.testclass
set objTest = new testdll.testclass
objTest.testmethod <--- this 'testmethod' doesn't display in intellisense... nothing does.
In addition i tried calling the 'testdll.testclass' via CreateObject, i get the error "ActiveX component can't create object"
Now i have other projects i've done COM visibility for and i've tried comparing the difference, but i don't see any. I can't understand why it isn't working.
Any clues??? tx very much.
Just use an interface... one you define or to use the [ClassInterface(ClassInterfaceType.AutoDual)]
there are comments online you can find that indicate not to use autodual, but if you control the complete usage of your library, it seems like an 'ok' way to go.
I tried all sorts of ways to simulate / understand why my one project didn't need an interface to be visible by an vb project, without success. i had originally thought perhaps possible that it was because that project implemented an IDisposable Interface (the ONLY interface used in the C# projects that is com visible) but that didn't turn out to be the reason. Anyway I don't want to waste anyone else's time on this. thanks for the responses.
this link provides ample information on the subject:
http://anturcynhyrfus.blogspot.com/2011/03/creating-com-visible-c-component.html

How to compile Shadows events using MSBuild

I am trying to use set up a CI server that doesn't depend on a Visual Studio installation but uses msbuild instead. Our solution includes an interop project. Visual Studio handles this project just fine, but msbuild seems to have a problem with events like this one, taken from an interop user control which inherits from System.Windows.Forms.UserControl:
Public Shadows Event Click() 'Event must be marked as Shadows since .NET UserControls have the same name.
The error I get from MSBuild is this:
error BC30029: Derived classes cannot raise base class events.
I read this, but my Event statement and RaiseEvent statements are already in the same class (the one from which the above error is being thrown). I don't think this solution applies to my situation.
What's the best way to get around this? Let me know if you need more information.
Thanks.

Resources