Question IWshRuntimeLibrary troubles.

ideprize

Well-known member
Joined
Oct 19, 2011
Messages
97
Programming Experience
10+
Hi to all

I have a working VB.net app developed under VS 2005 on a Windows 7 Pro 32 bit system. I moved the app to a Windows 8 Pro 64 bit system and the following synopsis takes place:

Windows 7 Pro 32 bit VS 2005
Reference interop.IWshRuntimeLibrary


Dim wh As New IWshRuntimeLibrary.IWshNetwork_Class
wh.SetDefaultPrinter(strDfltPtr)
Works




Windows 8 Pro 64 bit VS 2013
Reference IwshRuntimeLibrary (taken from windows\sysWOW64\wshom.ocr


Dim wh As New IWshRuntimeLibrary.IWshNetwork_Class
wh.SetDefaultPrinter(strDfltPtr)
Get
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in vbqtegen.exe
Additional information: Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))

I know there are a number of variables here but the only problem I am encountering is the setting of the "default printer". As shown in the synopsis I changed the IWshRuntimeLIbrary to its 64 bit version by adding it from the sysWOW64 folder. Why am I getting the exception. Am I wrong in thinking this is a 64 bit issue? Is it the .net version used by 2013 versus that used by vs 2005 - any help would be greatly appreciated. Thanks in advanced

Respectfully,
IDEPRIZE
 
Hi Jim
I would like the EXE to operate "Any CPU". I mentioned the 32/64 bit scenario because that is indeed a variable between the two development platforms. Thanks for the response.

Respectfully,
Ideprize
 
WOW64 means:
wiki said:
(Windows 32-bit on Windows 64-bit) is a subsystem of the Windows operating system capable of running 32-bit applications
Basically that means the library is 32-bit, and you have to compile your app for x86 for it to always run in 32-bit mode, even on 64-bit systems.
When you compiled for AnyCpu that caused the app to run in 64-bit mode in 64-bit Windows, and it crashed because the library didn't support 64-bit.
 
Thanks for the response John. I can use the original interop.IWshRuntimeLibrary reference but I get the same error. What I need to know is what should I use to allow the setDefaultPrinter statement to work. Is it the case that this particular object is "bit" sensitive? Nothing else seems to be impacted - "YET"!!!

Respectfully,
Ideprize
 
My apologies to all. It was the argument to the object not the object. I was inadvertently passing the "share" name and not the printer name. I have to get out of this "the sky is falling" syndrome!! Again my apologies.

Respectfully,
Ideprize
 
Back
Top