How to link VBA app against debug mode COM DLL - excel-2007

I am trying to debug an VBA excel app that invokes some functions from a C++ COM DLL.
I have added type library of the COM DDL in Tools--->References.
If i build the DLL in debug mode, VBA app complains about not finding the dll at run-time.
When i build the DLL in release mode, i am unable to debug it.
Does anyone knows how to link VBA against debug mode COM DLL ?

Once you set the dll in Debug mode, you will have to add the project file as reference in vba editor before running the macro that is using code of C++ COM DLL. You are also supposed to have the source code with you.

Related

VBA Runtime error '-2147221164 (80040154)': class not Registered

I developed a class library in Visual Studio 2019 using the .NET framework. Before building the project, I registered the.dll file to interop COM, and this process gave me a .tlb file. This class library was developed in VB.NET, besides that, it has a simple code: one class with one function (class calcular, function Soma):
It was possible to include the .tlb file in the reference of VBA and I develop a code in this language that uses the class of VB.NET to build the action of the button:
On the other hand, when I execute the code in VBA Excel it shows this message:
If a press the button debug "Depurar" VBA mark the line of the instance of the class
I read other questions about this error but there isn't a way to solve it without change my machine?
ADODB.Connection in VB6 - Open Method fails with Runtime Error '2147221164 (80040154)'
VBA Selenium "class not registered"- 80040154
I already made a repair in my MS Office getting to uninstall to install again, can you help me to solve this error that prevents a run of my library in Excel VBA?
.NET COM visible dlls should be registered using regasm utility with /codebase option.
Assembly Registration Tool
You must register the DLL before it can be used. Every time you compile a new version you need to run:
regsvr32.exe "fullPathAndFileName.dll"
You can add a post-build event to the Release in Visual Studio so that it registers the DLL every time you make a new release. If you are distributing this for others then you will need an installer that puts the DLL in to a proper location and then registers it.
You can unregister it by adding the /u flag
Microsoft Topic

Creating a VB.NET COM DLL

I have created a project in VB.NET, and I set "Make assembly COM visible". I have added 1 function to the project and then compiled it with admin rights.
I was under the impression that this is sufficient to make the project a COM exe, to register it and that I could consume it from within VB6.
However, when I try to add the .exe as a reference in VB6, VB6 says that it can't add a reference to the VB.NET .exe file.
What am I missing?
I have noticed that there is another checkbox named "Register for COM interop", but I'm not sure if I really need that.
I had to change the application style from Windows-Forms-App to Class Library.
Afterwards, I could check "Register for COM interop".
After compilation, a TLB would be created.
I could then reference this TLB.
That solved my problem.

Using VB, VS 2013 How to use a DLL outside of the working directory

I am using writing in Visual Basic using Visual Studio 2013 and trying to use the debuger for code in a DLL that is outside of the working directory. The dll is a c++ project and the main app is a VB project.
How do I do that? In c++ it seems to be straight forward but not with VB.
Below is purely for background. I am interested in the question above in general and this is just the latest manifestation.
The full story: I am trying to debug the VB program and a DLL written in C++. I copied the the DLL into the working directory of the VB exe directory. But it gives me a tool tip at the break point in the DLL source code that reads "breakpoint will not currently be hit. No symbols loaded for this document." I am trying to figure out if that fixes the problem. If it does, it does. If it doesn't, it doesn't.
Pehaps you should p-invoke (enter link description here) to make a call and import that .dll. The other option would be to register dll in gac and make wrapper com for your library.
You should also add the library to your .NET application as follows:
xcopy "$(SolutionDir)DLL\$(ConfigurationName)"\*.dll "$(TargetDir)"*.* /Y
Project-->Properties-->Compile-->Build Events-->Post-build event command line pass the command.

Generating a COM visible assembly from managed c++ (C++/CLI)

I need to develop some classes that should be callable from VB6 with Managed C++ (C++/CLI).
I've developed first a sample in C# and I can use the assembly through COM without problems
just using the setting "Register for COM interop" and "Make assembly COM visible" (and using the attribute [ClassInterface(ClassInterfaceType.AutoDual)] to make methods available at VB6.
After that I tried to translate the sample to C++/CLI without success. I've created the same class with the [ClassInterface(ClassInterfaceType.AutoDual)] attribute. I've set the "Embedded IDL" setting to specify the output TLB but the TLB is not generated automatically. If I use the tlbexp util over the generated DLL I get a tlb that can be imported at VB6 but when I try to create an instance I get an "ActiveX compoennt can't create object (429)"
What more do I need to do with the project to let it run?
Thanks in advance.
Not much to go on but you never mentioned registering the assembly. The C++ IDE doesn't have the "Register for COM interop" option. From the Visual Studio Command Prompt, run Regasm.exe on the assembly to get it registered. You need the /codebase option if you don't put the assembly in the GAC. And the /tlb option generates the type library, making tlbexp.exe unnecessary.

How do I debug a DLL from VS2008?

I have a program written in VB.Net (Visual Studio 2008) that uses a DLL written in Visual C++ by another developer. I'd like to be able to step in to the C++ code as my code makes calls to methods in the DLL. Since the DLL is it's own solution, I don't think it can be included in my solution/project. I tried putting the DLLs pdb file in the debug/bin directory with the rest of my build and pdb files. However, when I get to the point in stepping through my code, and it gets to the dll call, it just steps right over the dll code. Do I have to manually load symbols? Not sure what I'm doing wrong. Thanks.
There are 3 things you need to do here in order to debug this DLL. The first, as you mentioned, is to make sure the symbols for the native DLL is loaded,
The next is to enable unmanaged debugging since the DLL is native code. To do this
Right Click on the Project
Go to the Debug tab
Check the "Enable Unmanaged Debugging" check box
The last thing is to disable "Just My Code" for the project. I don't recall if this is strictly necessary when the second DLL is native. But in general it's good practice if you're debugging code which is not a part of your solution
Tools -> Options
Go to Debugging -> General
Uncheck "Enable Just my code"