how to debug COM dll
Hi, C# gurus,
I just made a COM dll using C#, which will be excuted from VBA code. Does any one know how to debug the COM in this case?
I set the Debug Mode of the C# project as Program and also specify the Start application, Excel. But, it seems not working.
Thanks.
# 1 Re: how to debug COM dll
1. Run Excel application.
2. Open your COM project in VS
3. In VS, Click on "Debug-> Processes" menu item
4. From the "Available processes" list, select the Excel process you just started and click attach.
Now you can set the break point in your COM project and do something that will invoke your COM object. See whether it works :)
# 2 Re: how to debug COM dll
Hi, poochi, thanks for your reply.
I am trying. I am not quite sure which of following I should choose when attaching to the Excel application:
Common Language Runtime
Native
If I do not check Native, an error says no managed code is running and .net debugger cannot be attached.
By the way, I have already solved the security policy problem by simply resetting all. I do not know why, but it is working any how.
Thanks a lot.
# 3 Re: how to debug COM dll
Hi, poochi,
It seems not working.
I use
Application.Run("comFunction")
to call function in an assembly.
It never returns and it never goes to the breakpoint in COM.
Do you have any idea what is going on?
Thanks.
CR
# 4 Re: how to debug COM dll
Could you please tell me the steps to call C# COM object from Excel VBA? I will try it here when I get time.
Glad to hear you fixed the COM registration problem. I didn't know the policy files affect COM registration.
# 5 Re: how to debug COM dll
Hi, poochi,
Here is how I did:
(1) In C# project, I build and register the COM.
It has a function like
public void test()
{
}
(2) In VBA, I add the registered COM to the reference list.
Using Object Brower, I can see the COM exports a function named test and it takes no arugment and returns nothing.
(3) In VBA code, I call the function
Application.Run("test")
Whenever the program exectues this line, it quits itself. Something must be wrong there, but I don't know.
Thanks,
CR