Error: Method ‘~’ of object ‘~’ failed
So yesterday at work, I was working with a sample app from one of our product vendors. The app was a VB6 Windows EXE showing how to interact with their equipment using sockets — Winsock. Since I’m under some pretty heavy time constraints, I wanted to make use of this code rather than pick through it and see what’s happening and translate to .NET. I was able to quickly turn the VB6 Win EXE into a VB6 COM DLL, and tested it from a VB6 test app, and it worked perfectly. However, when I reference the DLL from my .NET test app, things were not so great.
I had a few methods in the COM DLL that I was calling from my .NET code:
- Sub Connect — news up the Winsock object, sets the remote host and port, then connects.
- Sub DoSomethingWithWinsock (not the real name, but I don’t have the code here to look up the real name, but rest assured, it was equally as descriptive) — does a bunch of unimportant stuff, and then calls Winsock.Send(…)
- Function TestMethod — returns the current date/time as a string for testing
- Sub Disconnect — closes Winsock and sets it to nothing
When I call methods 1, 3 or 4 all seems to work well. When I call method 2 I get the error mentioned above: Method ‘~’ of object ‘~’ failed.
So, two questions to anyone that might read this:
- Any idea what the problem is and how to resolve it?
- Is there some way I can step into the VB6 code while debugging from VS2005?
I’ve already started picking through the code and rewriting with .NET equivalents, but I was hoping to avoid that.
Update: Sarma, a contractor that I’ve worked with recently, e-mailed me this link that has some good info. I haven’t tried it yet, but it sounds promising. If you’re looking to debug VB6 from VS, I’d definitely check it out. Thanks, Sarma!
By the way, Sarma was recently looking for a new contract. If anyone is hiring, contact me and I’ll connect you.