A Blog by Scott Isaacs

Tag: Software Projects Page 2 of 3

Interop Issue With Winsock

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:

  1. Sub Connect — news up the Winsock object, sets the remote host and port, then connects.
  2. 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(…)
  3. Function TestMethod — returns the current date/time as a string for testing
  4. 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:

  1. Any idea what the problem is and how to resolve it?
  2. 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.

New Tool: App Dashboard

Many times I find myself with way too many files, folders and shortcuts on the desktop for things that I am currently working on and/or testing.  That’s in addition, of course, to the things I have on the desktop because I use them all the time.  Because of the way I’ve grown to work over the last several years, having an overly cluttered desktop makes me inefficient.  In fact, I’ve found that I need to have certain types of icons in certain places, and “empty space” on the desktop in certain other places.

AppDashboard Yesterday, I found myself with too many shortcuts on the desktop, all related to my current project at work.  So I wrote a little utility that I called App Dashboard.  Basically, it’s a series of buttons that launch the applications I previously had a bunch of shortcuts for.  Initially, the paths were hardcoded, but I quickly changed my mind and allowed them to be user defined.  Then I decided that rather than define them in a config file of some sort, to actually create a document type for these groups of applications.

Thus was born App Dashboard.  You can download the binaries and/or the source below (usual disclaimer stuff here — use at your own risk, etc.).

Now I’m a big fan of SlickRun, so you’d think I’d just add MagicWords for these things, but the items I use App Dashboard for are more likely to fall into one of two categories:

  • They are temporal, and will only require quick access for a limited time, and I don’t feel that is worth adding them to SlickRun (just my personal opinion — take it or leave it).
  • They are items that I use a lot, and clicking a button is easier than typing a command when my hand is already on the mouse.  Actually, many of these things have MagicWords already, but switching from mouse to keyboard is a pain.  (It’s the little things…)

However, since App Dashboard has its own document type, I can easily create a MagicWord to open this dashboard or that dashboard.  I see myself using them both in various combinations.

Additionally, I’ve included some basic functionality for associating a file type with the app and for using an identifiable icon for the dashboard group files.  It’s optional, but you can run the install.bat file to setup these file type associations.  The application will work fine without running that, but installing will allow you to simply double click on a *.adsh file to open that dashboard.

Anyway, I welcome any comments or suggestions.  I don’t claim this to be a model example of how to accomplish any particular task.  I only claim that it may help you as it has helped me to keep myself and my computer slightly more organized and efficient.  If not, just delete it.  (Note that if you did run the install.bat file, I recommend you run uninstall.bat before deleting to remove the file type associations.  No need to leave that hanging around in Windows if you decide to not use App Dashboard.)

Seeking .NET Developer

I don’t often specifically mention my company when I blog, but we’re looking for a developer.  Short description: “VB 2005, SQL 2005, RFID”.  Slightly longer description here.  For even more info, please contact me directly — I get copied on messages sent to the e-mail alias on the job posting.  If you or someone you know is interested, please let me know.

CodePlex TFS Down?

I went to CodePlex to see what’s been going on with a couple projects since the last time I was there, and it seems that the Team Foundation Server is down.  I noticed it last night and it still seems to be down now.  I got a couple different error screens, depending on what I was trying to do.  This one when trying to view issues:

 And this one when going to the Source Code screen:

Anyway, there’s no real reason for posting this other than to post something.  So there.  I posted again.  Twice in one day.

Update #2: More IE Stuff

Early this year I posted a ZIP of stuff for IE context menus.  I just wrote and added another menu item for checking or unchecking any checkboxes in the current text selection.

The file is attached to this post.  Download and use at your own risk.  See readme.txt for summary and instructions.  These will modify your registry and if you don’t know what that implies, then you probably won’t want to install them.

Update: Image Converter

A couple weeks ago, I posted a “slightly useful piece of software” which could be used to convert a bunch of BMP files to JPG.  We’ll I just updated it to allow you to select the source and destination file types.

I’ve replaced the old download with the modified one, and you can get it here.  Use at your own risk.

It’s pretty simple to use, but see the original post for more info.  Let me know if you have any questions or suggestions.  I probably won’t put too much work into it, but if it’s a good suggestion, I may.

Update: More IE Stuff

A couple weeks ago, I posted about a ZIP of stuff for IE context menus.  I just updated the ZIP file to include a context menu item for getting a map for a highlighted address from Google Maps.

Here is the updated ZIP.  Download and use at your own risk.  See readme.txt for summary and instructions.  These will modify your registry and if you don’t know what that implies, then you probably won’t want to install them.

More IE Stuff

Some time back, I posted a little thing I hacked out to let me open un-linked URLs in a new window (in IE).  Well, I actually have a few very similar, ummm, things.  There are five parts in this ZIP.  You can pick and choose which ones you want to use.  Here they are:

In a nutshell, these each add a new menu item to your right-click menu in IE when you have text selected.  Once installed, select some text, right-click, pick the new option.  Pretty simple, hey?

Here is the ZIP.  Download and use at your own risk.  See readme.txt for summary and instructions.  These will modify your registry and if you don’t know what that implies, then you probably won’t want to install them.

Update: I’ve since added another “thing”.  Read the update post here.

Another (Slightly) Useful Piece of Software

OK, so this one may only be useful to one other person on the planet, but here it is.  (If you’re a .NET developer, then this is a trivial application.)

Anyway, my wife had a need to convert a bunch of BMP files into JPGs, and she doesn’t have Photoshop, or anything like that installed.  She could have done the conversion with MS Paint, one at a time, but that was cumbersome for a lot of images.  So I “whipped this together” for her.  In a nutshell, you specify a folder, and it creates JPG versions of all BMP files in that folder.  It doesn’t do any resizing, resampling, cropping, or anything else.  It just saves a copy in the new format — pretty basic.

For the .NET geek that might read this, I got 95% of the way (which was approximately equal to a whopping 20 lines of code) through this in VB 2005, then remembered that she doesn’t have the new framework installed.  So rather than spend the time installing that for her, I just copied the code into VB 2003 and finished there.  What can I say.  I’m lazy…  🙂

Anyway, here is the download.  Use at your own risk.  I zipped the entire solution, but if you’re not a developer and just want to use it, then look for the EXE in the “bin” folder.  You must have version 1.1 of the .NET framework installed for this to run, but if you’ve run Windows Update anytime in the last couple years, you probably do.

Newsletter Sender

OK, so that’s a really lame name for a program, but I named it so I wouldn’t forget what it was.  I could have called it PhireFaacs, but really, do you think I would know what that was in two weeks?  Forget for a moment how much ridicule I would receive from my peers for choosing such a stupid name — that’s an even dumber name than “Newsletter Sender”.

Anyway, I wrote a simple little WinForms program last night (screenshots below) to help me send out the newsletter for the WI .NET Users Group.  (See how I decided on the name???)  In a nutshell it does a mail merge of some comma delimeted text datasource against an e-mail template.  “So what?”, you ask.  Yeah, I asked that, too, but it does make my newsletter sending a little easier.

Basic instructions (because there is no help file or tooltips):

  • Specify an SMTP mail server, and optional SMTP username and password.
  • Load a data file.  This can be any CSV formatted file, but there must be row headers.
  • Specify which field in the data file contains e-mail addresses.
  • Enter the “from” address.
  • Enter the message subject.
  • Enter the message body.
  • Specify a priority.
  • Click “Send”

The SMTP mail server, SMTP username, and from address can be stored in an XML file that gets created the first time you run the program (you have to edit it manually).  The subject and body can contain placeholders ({0}, {1}, etc.) that will be replaced with data from that column (note that this is zero-based index).

That’s basically it.

The ZIP download is available here.  Blah blah blah your own risk blah blah blah I’m not responsible blah blah blah.

Screenshots (also included in ZIP download)

The UI:

A Merged E-mail:

Page 2 of 3

Powered by WordPress & Theme by Anders Norén