com >> %1 is not a valid win32 application

by Tony Proctor » Mon, 20 Mar 2006 23:09:09 GMT

Here's a good COM problem. I have a VB6 ActiveX EXE project that builds OK,
but I get the above error when I try to instantiate one of its classes from
a different EXE.

The error is also accompanied by an Event Log entry of ID 10000:

Unable to start a DCOM Server: {137DA12F-A721-45C3-9FD4-D44DE1B9E82A}.
The error:
"C:\AIM Tech\Server\MyExe.exe -Embedding is not a valid Win32
application. "
Happened while starting this command:
C:\AIM Tech\Server\MyExe.exe -Embedding

The -Embedding being one the standard command-line options pre-built into
any ActiveX EXE, just like -RegServer and -UnRegServer

This project used to work fine. Also, the same project builds and runs OK on
a different machine (the failing one is W2K Professional, and the working
one is W2K Server, but I can't believe this is important) Hence, my first
thought was that something was damaged in the registry on one machine.

Interestingly, it doesn't fail if I load-up the ActiveX EXE project into the
IDE, and it doesn't fail if I marshal it myself (i.e. by running the
associated command, including the -Embedding option, from a CMD prompt
before instantiating the class)

After a lot of trial and error, I looked at the CLSID entry for the class
being instantiated. Since the server's path contains spaces, I tried adding
quotes around the LocalServer32 sub-key, and it worked! However, my other
machine didn't need these quotes and the directory layout is identical.

Can anyone think of something I'm missing here?

Tony





com >> %1 is not a valid win32 application

by Tony Proctor » Tue, 21 Mar 2006 19:05:19 GMT


think I must have done something bad in a previous life to deserve this. I
long for the day when I have a straightforward problem to solve, or - better
still - none at all. :-(

I'm making some progress here, but there's still no answer in sight. I'm
sure I'm missing something obvious so any suggestions would be really,
really welcome folks.

My situation is now as follows:-

Any new ActiveX EXE project appears to work OK. However, it seems I have a
whole group of existing projects that fail in the way described. They all
have the following in common: (a) they're ActiveX EXE projects (i.e.
Type=OleExe in vbp file), (b) They're all on the same machine, (c) All their
VBP files were previously generated by an in-house configuration tool.

I started going down a blind alley by letting the IDE re-create the VBP
files, but it didn't help. I then unregistered all these failing projects,
plus all those in-house ones that they depend on, and then rebuilt the whole
project tree from scratch. This didn't help either. I then unregistered them
all again, went through the registry with a toothcomb to remove any old
artefacts that shouldn't be there, deleted all the associated EXE/DLL/OCX
files to prevent any Typelib inheritance, emptied the recycle bin, and
rebooted the machine. A rebuild of the project tree still didn't help. NB:
this effectively means now that no code or VBP files have changed since the
last working versions. Is that odd, or what?

This morning, I found that the "new" and working ActiveX EXE projects I was
creating only worked when I tried them in the C:\Program Files\Microsoft
Visual Studio\VB98 directory. I thought this was a reasonable test because
the path contains spaces. However, I unregistered one, moved it to the same
directories that hold our failing projects, and simply re-registered it with
/RegServer, i.e. no re-compilation. This then failed in the same way. Moving
it again to a directory with no spaces in its name made it work.

Hence, in summary, it seems something has broken with regard to launching
ActiveX EXE components from a path that contains spaces, unless that path is
C:\Program Files\Microsoft Visual Studio\VB98 which must be treated
differently somewhere along the way. This must mean that I'm looking for a
machine-wide difference rather than a project, build, or Typelib difference.

Arrgg!!

Tony Proctor

"Tony Proctor" < XXXX@XXXXX.COM > wrote in message
news:e8Ff# XXXX@XXXXX.COM ...
OK,
from
on
the
adding





com >> %1 is not a valid win32 application

by Tony Proctor » Wed, 22 Mar 2006 00:29:49 GMT

K, solved this one. Panic over...

My projects all fail if they're under a top-level directory with a name
beginning "AIM"<space>. Unfortunately, I have lots of them.

I did briefly look Q185126 (http://support.microsoft.com/kb/q185126/) but
dismissed that as something NT-specific that must have been fixed by now.

However, someone pointed me at this really interesting link:
http://www.idefense.com/intelligence/vulnerabilities/display.php?id=340.
This illustrates something I never knew about the processing of unquoted
file names that contain spaces in them. Sure enough, a quick scan of my
top-level directory on the C: drive uncovered a mysterious 0-length file
called "AIM" that shouldn't have been there. I've no idea how it got there
either. Removing that allowed everything to work normally again.

This is really worrying, though, because VB6 creates DCOM Server classes
with unquoted LocalServer32 entries, and I know of no way to override that -
other than by post-processing the entries after a build. It all means that
it's all too easy to fall foul of this issue, even when not using VB. I
found several references to the original error message on the newsgroups,
but almost no sound resolutions. I'd like to bet that this scenario would
account for a lot of them.

Tony Proctor

"Tony Proctor" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
I
better
their
whole
them
the
was
same
with
Moving
is
difference.
message
{137DA12F-A721-45C3-9FD4-D44DE1B9E82A}.
into
OK
working
first
class
other




Similar Threads

1. %1 is not a valid Win32 application in Process.Start() - VB.Net

2. EXE compiles but 'Not a valid Win32 Application

3. FTP - Using Win32 Shell.Application

4. Trying to run a non-Win32 Application

Hi,

I don't know if I am in the correct newsgroup.  If I am not, please let me 
know.

I have a dilemma that starts with MS Outlook.  I am trying to install 
updates onto the outlook Calendar without user intervention by using a 
vbScript.  The problem that is happening is that if a user clicks on a button 
in Outlook called "Add Holidays ..." then a GUI titled 'Add holidays to 
Calendar' is invoked.  If I double click on a particular file in the program 
directory, namely Outlook.hol, then the GUI titled 'Add holidays to Calendar' 
is invoked.  Another way of doing this is to navigate a DOS prompt to the 
folder where Outlook.HOL is located, type in Outlook.HOL and hit enter, then 
the GUI titled 'Add holidays to Calendar' is also invoked.  I just can't get 
the GUI to be invoked through vbscript.  Is there a way around my dilemma or 
is there a limitation in vbScript that I don't know about?

Thanks in advance,
JeffH

5. Can an exit(0) be sent to a VC++ Win32 Console Application process - Visual Basic/VB

6. Tcp Communication between VB.NET and delphi win32 applications

Hello

For one of ours projects we need to communicate with a tcp-server
written in vb.net.

Our application is the client and is written using D7 + indy ( version
installed by default ).

We get connected with the server and send a message to the server. The
message isn't read by the server software. When we sniff with wireshark
on the server machine, we see ours messages , but the server doesn't
responed to it. When running the server in debug, it isn't stopping at
the breakpoint where the data should be read.

I don't have any experiance with .net so i don't know where to start
looking !


Regards
Peter

7. Form Inheritance: Specified Cast Is Not Valid?

8. Cross-thread operation not valid error

I am trying to get data from several devices on serial ports back to a
form. I am struggling with handling the threading issues. I am also
trying to write the code for the devices in a self-contained class to
make it easier to reuse.

I have managed to get it to work by passing the form as a callback
object to the device class (and then using BeginInvoke on that
callback object in the Receiver method). However, this does not seem
to be a very elegant solution and seems to go against the principle of
object programming.

I thought that using events was equivalent to using delegates to
transfer control to a different thread but looks like am am doing
something wrong! The resulting error message is: "Cross-thread
operation not valid: Control 'tbLog' accessed from a thread other than
the thread it was created on."

Any help would be greatly appreciated.

The following is an extract from the code. The bulk of it has been
removed including the error handling but I hope I have left in the
relevant parts.

CODE:

'Class for each device
Public Class Device
    Private mintID As Integer
    Private WithEvents mIOPort As SerialPort
    Private Delegate Sub RxDelegate(ByVal RxData As String)
    Private mDlgt As New RxDelegate(AddressOf ProcessRxData)
    Private mRslt As System.IAsyncResult
'....
    Public Event RxData(ByVal intID As Integer, ByVal strData As
String)

    Private Sub Receiver(ByVal sender As Object, ByVal e As
SerialDataReceivedEventArgs) Handles mIOPort.DataReceived
	    mRslt = mDlgt.BeginInvoke(mIOPort.ReadLine, Nothing, Nothing)
    End Sub

    Private Sub ProcessRxData(ByVal strData As String)
        RaiseEvent RxData(mintID, strData)
        mDlgt.EndInvoke(mRslt)
    End Sub
'....
End Class

'--------------------------------------------------------

'Class for collection of devices
Public Class DeviceColl
    Inherits Dictionary(Of Integer, clsScaleIF)

    Public Event RxData(ByVal ID As Integer, ByVal strData As String)
'....
    Public Overloads Sub Add(ByVal ID As Integer, ByVal PortNum As
Nullable(Of Int16))
        Dim NewDevice = New Device(ID, PortNum)
		....
        AddHandler NewDevice.RxData, AddressOf RxDataHandler
    End Sub

    Public Sub RxDataHandler(ByVal ID As Integer, ByVal strData As
String)
        RaiseEvent RxData(ID, strData)
    End Sub
'....
End Class

'--------------------------------------------------------

'Main form for user interface
Public Class frmMain
    Dim WithEvents mDeviceList As DeviceColl
'....
    Public Sub Device_Rx(ByVal intID As Integer, ByVal strData As
String) Handles mDeviceList.RxData
        Log("Rx" & intID.ToString & ": " & strData)
    End Sub

    Private Sub Log(ByVal strText As String)
        tbLog.SelectedText = strText
    End Sub
'....
End Class