Discussion:
A program made by C# can not use a ATL/COM server...
(too old to reply)
heedong
2010-04-02 08:40:01 UTC
Permalink
Hi...

I am making programs in following environment.
. CPU : ARM series (marvell..)
. Platform : Windows CE 5.0

1) COM server program
- made by ATL(server type is executable[exe]) / out of process with EVC++
- file name : ComExe.exe

2) Client program
- made by visual C# 2005 (Smart Device/Windows CE 5.0)
- file name : TestComExe.exe

"TestComExe.exe" calls a function which is served in "ComeExe.exe" simply.
before "ComeEx.exe" is registered by "ComExe.exe /Regserver" in the device.

C# code --------------------------------------------
using COMEXELib;
...
COMEXELib.ComCtrl objComCtrl = null;
...
objComCtrl = new COMEXELib.ComCtrl(); => exception error
...

the error message is
"System.Runtime.Interopservices.COMException(0x800706B5)..."

I don't know how to solve the problem at all.

I did the same things in a desktop PC. There was no problem.
"TestComExe.exe" correctly called the function in "ComExe.exe" without any
problem.

What can I do to solve the problem?
Please! could you tell me how to solve it?
Paul G. Tobey [eMVP]
2010-04-05 15:11:01 UTC
Permalink
I'd say that you should trap the exception. Clearly this is an invalid
situation. You're trying to create an object before the type is registered,
right? Invalid, correct?

I can't explain why this would work on the PC, since it's an equally invalid
operation there, but it's clearly wrong, so either a) don't do that or, b)
catch the illegal operation and handle it.

Paul T.
Post by heedong
Hi...
I am making programs in following environment.
. CPU : ARM series (marvell..)
. Platform : Windows CE 5.0
1) COM server program
- made by ATL(server type is executable[exe]) / out of process with EVC++
- file name : ComExe.exe
2) Client program
- made by visual C# 2005 (Smart Device/Windows CE 5.0)
- file name : TestComExe.exe
"TestComExe.exe" calls a function which is served in "ComeExe.exe" simply.
before "ComeEx.exe" is registered by "ComExe.exe /Regserver" in the device.
C# code --------------------------------------------
using COMEXELib;
...
COMEXELib.ComCtrl objComCtrl = null;
...
objComCtrl = new COMEXELib.ComCtrl(); => exception error
...
the error message is
"System.Runtime.Interopservices.COMException(0x800706B5)..."
I don't know how to solve the problem at all.
I did the same things in a desktop PC. There was no problem.
"TestComExe.exe" correctly called the function in "ComExe.exe" without any
problem.
What can I do to solve the problem?
Please! could you tell me how to solve it?
sta2002
2010-04-06 00:59:23 UTC
Permalink
Thank you for your response.

After "ComExe.exe" was registered, "TestCom.exe" was executed.
So It is not true that I'm trying to create an object before the type is
registered.


I searched the information of "ComExe.exe" in the registry of a device with
"Remote Registry Editor(WCE500)."
Isn't "ComExe.exe" registered in the registry of a device?

I don't know the reason that there is no any problem on the environment of a
PC and there is a problem on the environment of a device(window ce - mobile
device)

C# codes are very simple.

------------------------------------------------------------------------------
--------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//using ComExe_Metadata;
using COMEXELib; // "ComExe.tlb" is referenced

namespace TestComExe
{
public partial class Form1 : Form
{
//ComExe_Metadata.ComCtrl objComCtrl = null;
COMEXELib.ComCtrl objComCtrl = null;

public Form1()
{
InitializeComponent();

//objComCtrl = new ComExe_Metadata.ComCtrl();
try
{
objComCtrl = new COMEXELib.ComCtrl(); // => exception error
}
catch (Exception ex)
{
MessageBox.Show("the object of ComCtrl can not be created :"
+ ex.ToString());
}
}
}
}
------------------------------------------------------------------------------
--------------------------------------------------------

Please, let's me know how to solve it
Post by Paul G. Tobey [eMVP]
I'd say that you should trap the exception. Clearly this is an invalid
situation. You're trying to create an object before the type is registered,
right? Invalid, correct?
I can't explain why this would work on the PC, since it's an equally invalid
operation there, but it's clearly wrong, so either a) don't do that or, b)
catch the illegal operation and handle it.
Paul T.
Post by heedong
Hi...
[quoted text clipped - 32 lines]
Post by heedong
What can I do to solve the problem?
Please! could you tell me how to solve it?
sta2002
2010-04-06 00:59:22 UTC
Permalink
Thank you for your response.

After "ComExe.exe" was registered, "TestCom.exe" was executed.
So It is not true that I'm trying to create an object before the type is
registered.


I searched the information of "ComExe.exe" in the registry of a device with
"Remote Registry Editor(WCE500)."
Isn't "ComExe.exe" registered in the registry of a device?

I don't know the reason that there is no any problem on the environment of a
PC and there is a problem on the environment of a device(window ce - mobile
device)

C# codes are very simple.

------------------------------------------------------------------------------
--------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//using ComExe_Metadata;
using COMEXELib; // "ComExe.tlb" is referenced

namespace TestComExe
{
public partial class Form1 : Form
{
//ComExe_Metadata.ComCtrl objComCtrl = null;
COMEXELib.ComCtrl objComCtrl = null;

public Form1()
{
InitializeComponent();

//objComCtrl = new ComExe_Metadata.ComCtrl();
try
{
objComCtrl = new COMEXELib.ComCtrl(); // => exception error
}
catch (Exception ex)
{
MessageBox.Show("the object of ComCtrl can not be created :"
+ ex.ToString());
}
}
}
}
------------------------------------------------------------------------------
--------------------------------------------------------

Please, let's me know how to solve it
Post by Paul G. Tobey [eMVP]
I'd say that you should trap the exception. Clearly this is an invalid
situation. You're trying to create an object before the type is registered,
right? Invalid, correct?
I can't explain why this would work on the PC, since it's an equally invalid
operation there, but it's clearly wrong, so either a) don't do that or, b)
catch the illegal operation and handle it.
Paul T.
Post by heedong
Hi...
[quoted text clipped - 32 lines]
Post by heedong
What can I do to solve the problem?
Please! could you tell me how to solve it?
Paul G. Tobey [eMVP]
2010-04-06 03:52:15 UTC
Permalink
You *said* that this was happening *before* you registered the executable.

Exactly how it's wrong, I can't say. Since you must be experienced with
COM, verify that the right GUIDs are in the registry, as they would be on
the PC. If they are, verify that your operating system has the DCOM
component in it. Since you are using out-of-process COM, you have to have
the DCOM component, if I recall correctly. If you are the OS builder for
this device, build a DEBUG build of the OS and you should get more-detailed
information in the debug messages from the operating system when you try to
create the object.

Paul T.
Post by sta2002
Thank you for your response.
After "ComExe.exe" was registered, "TestCom.exe" was executed.
So It is not true that I'm trying to create an object before the type is
registered.
I searched the information of "ComExe.exe" in the registry of a device with
"Remote Registry Editor(WCE500)."
Isn't "ComExe.exe" registered in the registry of a device?
I don't know the reason that there is no any problem on the environment of a
PC and there is a problem on the environment of a device(window ce - mobile
device)
C# codes are very simple.
------------------------------------------------------------------------------
--------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//using ComExe_Metadata;
using COMEXELib; // "ComExe.tlb" is referenced
namespace TestComExe
{
public partial class Form1 : Form
{
//ComExe_Metadata.ComCtrl objComCtrl = null;
COMEXELib.ComCtrl objComCtrl = null;
public Form1()
{
InitializeComponent();
//objComCtrl = new ComExe_Metadata.ComCtrl();
try
{
objComCtrl = new COMEXELib.ComCtrl(); // => exception error
}
catch (Exception ex)
{
MessageBox.Show("the object of ComCtrl can not be created :"
+ ex.ToString());
}
}
}
}
------------------------------------------------------------------------------
--------------------------------------------------------
Please, let's me know how to solve it
Post by Paul G. Tobey [eMVP]
I'd say that you should trap the exception. Clearly this is an invalid
situation. You're trying to create an object before the type is registered,
right? Invalid, correct?
I can't explain why this would work on the PC, since it's an equally invalid
operation there, but it's clearly wrong, so either a) don't do that or, b)
catch the illegal operation and handle it.
Paul T.
Post by heedong
Hi...
[quoted text clipped - 32 lines]
Post by heedong
What can I do to solve the problem?
Please! could you tell me how to solve it?
sta2002 via PocketPCJunkies.com
2010-04-08 11:10:35 UTC
Permalink
Thank you for the quickly reply.

I haven't solve the problem yet.

I have compared the registry between the a PC and a mobile device.
There was difference.

There is no the uuid of "IComExeCtrl" on the mobile device.
If the command of "ComExe.exe /Regserver" is executed on the mobile device,
then all information of registry on "ComExe.exe" is configured. isn't it?

And there is "readmePS.txt" in the project folder of "ComExe.exe" (EVC++)
the content is the following :
========================================================================
Creating the Proxy Stub DLL Project
========================================================================
A proxy/stub DLL is needed if you plan to use standard marshalling
between your ATL COM server and its clients.
The following illustrates how to add a proxy/stub DLL project to
your ATL COM server workspace.

1. With the ATL .EXE workspace open and already built, Create
a WCE Dynamic-Link Library project with the appwizard.
Click on the "Add to current" workspace button.

2. Name the DLL project something like ComExePS

3. Click OK and then choose the "An empty Windows CE DLL project" option.

4. Goto Project->Dependencies and make the DLL project
dependent on the EXE project

5. Now add the following files to the proxy stub DLL project.
?Dlldata.c
?ComExeps.def
?ComExe_i.c
?ComExe_p.c


6. Open the project settings dialog for the DLL project and click
on the C++ tab. Add WIN32 and REGISTER_PROXY_DLL to the
Preprocessor Definitions edit box.

7. Now click on the Link tab and add rpcrt4.lib, uuid.lib, and
oleaut32.lib to the Object/library modules edit box. You should
now be able to build the dll with no problems.
------------------------------------------------------------------------------
-----------------------------------------
I've made Proxy Stub DLL Project by instructions of the above statement.
After building, "ComExePS.dll" is created.
I wonder what the dll is, how can I use it?

I would appreciate if you tell me details about these.
And lastly I really wonder that COM(out of process server) is supported on
WinCE 5.0.

thank you.
Post by Paul G. Tobey [eMVP]
You *said* that this was happening *before* you registered the executable.
Exactly how it's wrong, I can't say. Since you must be experienced with
COM, verify that the right GUIDs are in the registry, as they would be on
the PC. If they are, verify that your operating system has the DCOM
component in it. Since you are using out-of-process COM, you have to have
the DCOM component, if I recall correctly. If you are the OS builder for
this device, build a DEBUG build of the OS and you should get more-detailed
information in the debug messages from the operating system when you try to
create the object.
Paul T.
Post by sta2002
Thank you for your response.
[quoted text clipped - 74 lines]
Post by sta2002
Post by heedong
What can I do to solve the problem?
Please! could you tell me how to solve it?
--
Message posted via http://www.pocketpcjunkies.com
Paul G. Tobey [eMVP]
2010-04-08 20:04:09 UTC
Permalink
Post by sta2002 via PocketPCJunkies.com
I have compared the registry between the a PC and a mobile device.
There was difference.
There is no the uuid of "IComExeCtrl" on the mobile device.
If the command of "ComExe.exe /Regserver" is executed on the mobile device,
then all information of registry on "ComExe.exe" is configured. isn't it?
You're in control of what happens! My guess is that you're counting on ATL
to do the right thing. If so, what happens is that the code contains some
macro invocations which create data structures that ATL then uses, when
/regserver is passed, to make the registry entries.
Post by sta2002 via PocketPCJunkies.com
And there is "readmePS.txt" in the project folder of "ComExe.exe" (EVC++)
========================================================================
Creating the Proxy Stub DLL Project
========================================================================
A proxy/stub DLL is needed if you plan to use standard marshalling
between your ATL COM server and its clients.
The following illustrates how to add a proxy/stub DLL project to
your ATL COM server workspace.
1. With the ATL .EXE workspace open and already built, Create
a WCE Dynamic-Link Library project with the appwizard.
Click on the "Add to current" workspace button.
2. Name the DLL project something like ComExePS
3. Click OK and then choose the "An empty Windows CE DLL project" option.
4. Goto Project->Dependencies and make the DLL project
dependent on the EXE project
5. Now add the following files to the proxy stub DLL project.
?Dlldata.c
?ComExeps.def
?ComExe_i.c
?ComExe_p.c
6. Open the project settings dialog for the DLL project and click
on the C++ tab. Add WIN32 and REGISTER_PROXY_DLL to the
Preprocessor Definitions edit box.
7. Now click on the Link tab and add rpcrt4.lib, uuid.lib, and
oleaut32.lib to the Object/library modules edit box. You should
now be able to build the dll with no problems.
------------------------------------------------------------------------------
-----------------------------------------
I've made Proxy Stub DLL Project by instructions of the above statement.
After building, "ComExePS.dll" is created.
I wonder what the dll is, how can I use it?
Ah! Now we see something of what's going on. Yes, you must have a proxy
for the out-of-process object (you know how COM works, right? You need an
in-process stub object that can send your calls and parameters to the object
running in the other process). If you build the proxy and the stub and
deploy them to the target device, the IDE will self-register them. You don't
have to do anything else.

If you don't know what a proxy and a stub are for, YOU HAVE TO LEARN A LOT
MORE ABOUT COM. It's not like on the desktop where everything with COM is
free and you have to do very little to create COM objects and use them. You
have to actually understand COM to work with it on CE. Even reading the
first half of, say, Inside OLE, would give you an understanding of proxies,
stubs, in-process and out-of-process, threading models, type libraries, etc.
Post by sta2002 via PocketPCJunkies.com
I would appreciate if you tell me details about these.
And lastly I really wonder that COM(out of process server) is supported on
WinCE 5.0.
Yes, it *CAN BE* supported on CE5. Remember that CE5 is not a single thing
about which you can make general statements like "COM is supported" or "out
of process COM is supported". The device OEM decides what components of the
operating system will be present and which WILL NOT. If the DCOM component
is not in the OS, then, no there's no out-of-process COM support and nothing
you can do about it.

Paul T.
sta2002 via PocketPCJunkies.com
2010-04-12 06:39:02 UTC
Permalink
Hi Paul.

I'am studying more ATL/COM in books and on the internet.

After I registered tow items in registry : they are "ComExe.exe" and Proxy
Stub for "ComExe.exe".
and I executed "TestComExe.exe".

Generally, if "TestComExe.exe" is executed, then "ComExe.exe" is
automatically run,
but "ComExe.exe" wasn't run on my target device. so I added logs to "tWinMain
(...)" of "ComExe.exe" as soon as calling it. I again executed "TestCom.exe"
and I checked the log.
There are no any log. I think that COM library doesn't call "ComExeCE.exe".


I'd like to check how to register for "ComExe.exe" is like the following

1) "\Temp\ComExe.exe /RegServer".
- to register ComExe.exe in the registry of a mobile device.
2) "regsvrce \Temp\ComExePS.dll".
- to register the proxy strub of ComExe.exe in the registry of a mobile
device.

Is it correct to execute tow command to register for "ComExe.exe"?

COM client(a application using "ComExe.exe") is made by MFC.
- I made COM client again by MFC.

COM client source code -------------------------------------------------------
----------------
..
if (CoInitializeEx(NULL, COINIT_MULTITHREADED)<0)
..
rc = CLSIDFromProgID(OLESTR("ComExe.ComExeCtrl.1"),&clsid);
..
rc = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**)
&pUnk);
..

a error occurs. the value of rc is 0x800706b5. (unknown interface error)

The following lists are the information of registry after executing tow
commands : 1) and 2)
※ Note : I changed the name of COM server form "ComExe.exe" to "ComExeCE1.
exe"
and I also changed the name of the proxy stub for COM server
from "ComExePS.dll" to "ComExeCE1PS.dll"

after executing 1) -----------------------------------------------------------
------------------------------------------------
"\temp\ComExe.exe /RegServer"

[HKEY_CLASSES_ROOT\AppID]

[HKEY_CLASSES_ROOT\AppID\{2DAF649E-1C9E-4FE9-8174-91ABD21B342E}]
@="ComExeCE1"

[HKEY_CLASSES_ROOT\AppID\ComExeCE1.EXE]
"AppID"="{2DAF649E-1C9E-4FE9-8174-91ABD21B342E}"
-----------------------------------------------------------------------
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}]
@="ComExeCE1Ctrl Class"
"AppID"="{2DAF649E-1C9E-4FE9-8174-91ABD21B342E}"

[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\LocalServer32]

@="\\Temp\\ComExeCE1.exe"

[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\ProgID]
@="ComExeCE1.ComExeCE1Ctrl.1"

[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\Programmable]

[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\TypeLib]
@="{BBA781BE-56F1-4A39-9804-45280042A2FF}"

[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\
VersionIndependentProgID]
@="ComExeCE1.ComExeCE1Ctrl"
------------------------------------------------------------------------------
-------------
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl]
@="ComExeCE1Ctrl Class"

[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl\CLSID]
@="{5901474F-EEB3-40BF-B4D5-8889BF30334E}"

[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl\CurVer]
@="ComExeCE1.ComExeCE1Ctrl.1"

[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl.1]
@="ComExeCE1Ctrl Class"

[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl.1\CLSID]
@="{5901474F-EEB3-40BF-B4D5-8889BF30334E}"
------------------------------------------------------------------------------
-------------
[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}]

[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}\1.0]

[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}\1.0\0]
@="\\Temp\\ComExeCE1.exe"

[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}\1.0\0\win32]

@="\\Temp\\ComExeCE1.exe"
------------------------------------------------------------------------------
-------------


after executing 2)------------------------------------------------------------
-------------------------------
"regsvrce \temp\ComExePS.dll"

[HKEY_CLASSES_ROOT\CLSID\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}]
@="PSFactoryBuffer"

[HKEY_CLASSES_ROOT\CLSID\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}\
InProcServer32]
@="\\Temp\\ComExeCE1PS.dll"
"ThreadingModel"="Both"
------------------------------------------------------------------------------
-------------
[HKEY_CLASSES_ROOT\INTERFACE\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}]
@="IComExeCE1Ctrl"

[HKEY_CLASSES_ROOT\INTERFACE\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}\
NumMethods]
@="9"

[HKEY_CLASSES_ROOT\INTERFACE\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}\
ProxyStubClsid32]
@="{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}"

------------------------------------------------------------------------------
-------------------------------------------------------------------

I always appreciate your help.
Post by Paul G. Tobey [eMVP]
Post by sta2002 via PocketPCJunkies.com
I have compared the registry between the a PC and a mobile device.
There was difference.
There is no the uuid of "IComExeCtrl" on the mobile device.
If the command of "ComExe.exe /Regserver" is executed on the mobile device,
then all information of registry on "ComExe.exe" is configured. isn't it?
You're in control of what happens! My guess is that you're counting on ATL
to do the right thing. If so, what happens is that the code contains some
macro invocations which create data structures that ATL then uses, when
/regserver is passed, to make the registry entries.
Post by sta2002 via PocketPCJunkies.com
And there is "readmePS.txt" in the project folder of "ComExe.exe" (EVC++)
[quoted text clipped - 36 lines]
Post by sta2002 via PocketPCJunkies.com
After building, "ComExePS.dll" is created.
I wonder what the dll is, how can I use it?
Ah! Now we see something of what's going on. Yes, you must have a proxy
for the out-of-process object (you know how COM works, right? You need an
in-process stub object that can send your calls and parameters to the object
running in the other process). If you build the proxy and the stub and
deploy them to the target device, the IDE will self-register them. You don't
have to do anything else.
If you don't know what a proxy and a stub are for, YOU HAVE TO LEARN A LOT
MORE ABOUT COM. It's not like on the desktop where everything with COM is
free and you have to do very little to create COM objects and use them. You
have to actually understand COM to work with it on CE. Even reading the
first half of, say, Inside OLE, would give you an understanding of proxies,
stubs, in-process and out-of-process, threading models, type libraries, etc.
Post by sta2002 via PocketPCJunkies.com
I would appreciate if you tell me details about these.
And lastly I really wonder that COM(out of process server) is supported on
WinCE 5.0.
Yes, it *CAN BE* supported on CE5. Remember that CE5 is not a single thing
about which you can make general statements like "COM is supported" or "out
of process COM is supported". The device OEM decides what components of the
operating system will be present and which WILL NOT. If the DCOM component
is not in the OS, then, no there's no out-of-process COM support and nothing
you can do about it.
Paul T.
--
Message posted via http://www.pocketpcjunkies.com
sta2002 via PocketPCJunkies.com
2010-04-12 06:44:42 UTC
Permalink
Additionally,

The error occurred at CoCreateInstance()
the value is 0x800706b5. (unknown interface error)
Post by sta2002 via PocketPCJunkies.com
Hi Paul.
I'am studying more ATL/COM in books and on the internet.
After I registered tow items in registry : they are "ComExe.exe" and Proxy
Stub for "ComExe.exe".
and I executed "TestComExe.exe".
Generally, if "TestComExe.exe" is executed, then "ComExe.exe" is
automatically run,
but "ComExe.exe" wasn't run on my target device. so I added logs to "tWinMain
(...)" of "ComExe.exe" as soon as calling it. I again executed "TestCom.exe"
and I checked the log.
There are no any log. I think that COM library doesn't call "ComExeCE.exe".
I'd like to check how to register for "ComExe.exe" is like the following
1) "\Temp\ComExe.exe /RegServer".
- to register ComExe.exe in the registry of a mobile device.
2) "regsvrce \Temp\ComExePS.dll".
- to register the proxy strub of ComExe.exe in the registry of a mobile
device.
Is it correct to execute tow command to register for "ComExe.exe"?
COM client(a application using "ComExe.exe") is made by MFC.
- I made COM client again by MFC.
COM client source code -------------------------------------------------------
----------------
...
if (CoInitializeEx(NULL, COINIT_MULTITHREADED)<0)
...
rc = CLSIDFromProgID(OLESTR("ComExe.ComExeCtrl.1"),&clsid);
...
rc = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**)
&pUnk);
...
a error occurs. the value of rc is 0x800706b5. (unknown interface error)
The following lists are the information of registry after executing tow
commands : 1) and 2)
※ Note : I changed the name of COM server form "ComExe.exe" to "ComExeCE1.
exe"
and I also changed the name of the proxy stub for COM server
from "ComExePS.dll" to "ComExeCE1PS.dll"
after executing 1) -----------------------------------------------------------
------------------------------------------------
"\temp\ComExe.exe /RegServer"
[HKEY_CLASSES_ROOT\AppID]
[HKEY_CLASSES_ROOT\AppID\{2DAF649E-1C9E-4FE9-8174-91ABD21B342E}]
@="ComExeCE1"
[HKEY_CLASSES_ROOT\AppID\ComExeCE1.EXE]
"AppID"="{2DAF649E-1C9E-4FE9-8174-91ABD21B342E}"
-----------------------------------------------------------------------
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}]
@="ComExeCE1Ctrl Class"
"AppID"="{2DAF649E-1C9E-4FE9-8174-91ABD21B342E}"
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\LocalServer32]
@="\\Temp\\ComExeCE1.exe"
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\ProgID]
@="ComExeCE1.ComExeCE1Ctrl.1"
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\Programmable]
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\TypeLib]
@="{BBA781BE-56F1-4A39-9804-45280042A2FF}"
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\
VersionIndependentProgID]
@="ComExeCE1.ComExeCE1Ctrl"
------------------------------------------------------------------------------
-------------
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl]
@="ComExeCE1Ctrl Class"
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl\CLSID]
@="{5901474F-EEB3-40BF-B4D5-8889BF30334E}"
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl\CurVer]
@="ComExeCE1.ComExeCE1Ctrl.1"
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl.1]
@="ComExeCE1Ctrl Class"
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl.1\CLSID]
@="{5901474F-EEB3-40BF-B4D5-8889BF30334E}"
------------------------------------------------------------------------------
-------------
[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}]
[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}\1.0]
[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}\1.0\0]
@="\\Temp\\ComExeCE1.exe"
[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}\1.0\0\win32]
@="\\Temp\\ComExeCE1.exe"
------------------------------------------------------------------------------
-------------
after executing 2)------------------------------------------------------------
-------------------------------
"regsvrce \temp\ComExePS.dll"
[HKEY_CLASSES_ROOT\CLSID\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}]
@="PSFactoryBuffer"
[HKEY_CLASSES_ROOT\CLSID\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}\
InProcServer32]
@="\\Temp\\ComExeCE1PS.dll"
"ThreadingModel"="Both"
------------------------------------------------------------------------------
-------------
[HKEY_CLASSES_ROOT\INTERFACE\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}]
@="IComExeCE1Ctrl"
[HKEY_CLASSES_ROOT\INTERFACE\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}\
NumMethods]
@="9"
[HKEY_CLASSES_ROOT\INTERFACE\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}\
ProxyStubClsid32]
@="{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}"
------------------------------------------------------------------------------
-------------------------------------------------------------------
I always appreciate your help.
Post by Paul G. Tobey [eMVP]
Post by sta2002 via PocketPCJunkies.com
I have compared the registry between the a PC and a mobile device.
There was difference.
[quoted text clipped - 40 lines]
Post by Paul G. Tobey [eMVP]
Paul T.
--
Message posted via http://www.pocketpcjunkies.com
Paul G. Tobey [eMVP]
2010-04-12 16:26:01 UTC
Permalink
Then I'd say that you're asking for an interface to whatever object you've
created that the object doesn't have. Without seeing the client code, we
can't possibly guess what that might be.

Paul T.
Post by sta2002 via PocketPCJunkies.com
Additionally,
The error occurred at CoCreateInstance()
the value is 0x800706b5. (unknown interface error)
Post by sta2002 via PocketPCJunkies.com
Hi Paul.
I'am studying more ATL/COM in books and on the internet.
After I registered tow items in registry : they are "ComExe.exe" and Proxy
Stub for "ComExe.exe".
and I executed "TestComExe.exe".
Generally, if "TestComExe.exe" is executed, then "ComExe.exe" is
automatically run,
but "ComExe.exe" wasn't run on my target device. so I added logs to "tWinMain
(...)" of "ComExe.exe" as soon as calling it. I again executed "TestCom.exe"
and I checked the log.
There are no any log. I think that COM library doesn't call "ComExeCE.exe".
I'd like to check how to register for "ComExe.exe" is like the following
1) "\Temp\ComExe.exe /RegServer".
- to register ComExe.exe in the registry of a mobile device.
2) "regsvrce \Temp\ComExePS.dll".
- to register the proxy strub of ComExe.exe in the registry of a mobile
device.
Is it correct to execute tow command to register for "ComExe.exe"?
COM client(a application using "ComExe.exe") is made by MFC.
- I made COM client again by MFC.
COM client source code -------------------------------------------------------
----------------
...
if (CoInitializeEx(NULL, COINIT_MULTITHREADED)<0)
...
rc = CLSIDFromProgID(OLESTR("ComExe.ComExeCtrl.1"),&clsid);
...
rc = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**)
&pUnk);
...
a error occurs. the value of rc is 0x800706b5. (unknown interface error)
The following lists are the information of registry after executing tow
commands : 1) and 2)
※ Note : I changed the name of COM server form "ComExe.exe" to "ComExeCE1.
exe"
and I also changed the name of the proxy stub for COM server
from "ComExePS.dll" to "ComExeCE1PS.dll"
after executing 1) -----------------------------------------------------------
------------------------------------------------
"\temp\ComExe.exe /RegServer"
[HKEY_CLASSES_ROOT\AppID]
[HKEY_CLASSES_ROOT\AppID\{2DAF649E-1C9E-4FE9-8174-91ABD21B342E}]
@="ComExeCE1"
[HKEY_CLASSES_ROOT\AppID\ComExeCE1.EXE]
"AppID"="{2DAF649E-1C9E-4FE9-8174-91ABD21B342E}"
-----------------------------------------------------------------------
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}]
@="ComExeCE1Ctrl Class"
"AppID"="{2DAF649E-1C9E-4FE9-8174-91ABD21B342E}"
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\LocalServer32]
@="\\Temp\\ComExeCE1.exe"
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\ProgID]
@="ComExeCE1.ComExeCE1Ctrl.1"
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\Programmable]
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\TypeLib]
@="{BBA781BE-56F1-4A39-9804-45280042A2FF}"
[HKEY_CLASSES_ROOT\CLSID\{5901474F-EEB3-40BF-B4D5-8889BF30334E}\
VersionIndependentProgID]
@="ComExeCE1.ComExeCE1Ctrl"
------------------------------------------------------------------------------
-------------
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl]
@="ComExeCE1Ctrl Class"
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl\CLSID]
@="{5901474F-EEB3-40BF-B4D5-8889BF30334E}"
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl\CurVer]
@="ComExeCE1.ComExeCE1Ctrl.1"
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl.1]
@="ComExeCE1Ctrl Class"
[HKEY_CLASSES_ROOT\ComExeCE1.ComExeCE1Ctrl.1\CLSID]
@="{5901474F-EEB3-40BF-B4D5-8889BF30334E}"
------------------------------------------------------------------------------
-------------
[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}]
[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}\1.0]
[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}\1.0\0]
@="\\Temp\\ComExeCE1.exe"
[HKEY_CLASSES_ROOT\TypeLib\{BBA781BE-56F1-4A39-9804-45280042A2FF}\1.0\0\win32]
@="\\Temp\\ComExeCE1.exe"
------------------------------------------------------------------------------
-------------
after executing 2)------------------------------------------------------------
-------------------------------
"regsvrce \temp\ComExePS.dll"
[HKEY_CLASSES_ROOT\CLSID\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}]
@="PSFactoryBuffer"
[HKEY_CLASSES_ROOT\CLSID\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}\
InProcServer32]
@="\\Temp\\ComExeCE1PS.dll"
"ThreadingModel"="Both"
------------------------------------------------------------------------------
-------------
[HKEY_CLASSES_ROOT\INTERFACE\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}]
@="IComExeCE1Ctrl"
[HKEY_CLASSES_ROOT\INTERFACE\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}\
NumMethods]
@="9"
[HKEY_CLASSES_ROOT\INTERFACE\{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}\
ProxyStubClsid32]
@="{8045F0BF-CB95-40F1-88DF-DAA0A55906BB}"
------------------------------------------------------------------------------
-------------------------------------------------------------------
I always appreciate your help.
Post by Paul G. Tobey [eMVP]
Post by sta2002 via PocketPCJunkies.com
I have compared the registry between the a PC and a mobile device.
There was difference.
[quoted text clipped - 40 lines]
Post by Paul G. Tobey [eMVP]
Paul T.
--
Message posted via http://www.pocketpcjunkies.com
.
sta2002 via PocketPCJunkies.com
2010-04-13 01:34:55 UTC
Permalink
1) out of process COM server
. filename : ComExeCE11.exe
. made by a project of WCE ATL COM AppWizard (EVC++ 4.0)

2) Proxy Stub for COM server
. filename : ComExeCE11PS.dll
. made by a project of WCE Dynamic-Link Library

3) COM client
. filename : Test_ComExeCE11.exe
. made by the project of WCE Application (EVC++ 4.0)

the following source codes are on ComExeCE11.exe and Test_ComExeCE11.exe
//===================================================
// COM server source
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.idl : IDL source for ComExeCE11.dll
//
// This file will be processed by the MIDL tool to
// produce the type library (ComExeCE11.tlb) and marshalling code.
//----------------------------------------------------------------------------
---------------------------
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(E5DEE0DC-15C4-4EE8-AB6F-EFB9B0747B2C),
dual,
helpstring("IComExeCE11Ctrl Interface"),
pointer_default(unique)
]
interface IComExeCE11Ctrl : IDispatch
{
[id(1), helpstring("method Function")] HRESULT Function();
[id(2), helpstring("method _com_issue_errorex")] HRESULT _com_issue_errorex
(HRESULT _hr1, IUnknown *pthis1, const GUID refiid1);
};

[
uuid(4B7E4501-9B22-4D5B-8241-2E11F2B993A3),
version(1.0),
helpstring("ComExeCE11 1.0 Type Library")
]
library COMEXECE11Lib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");

[
uuid(C163B931-E486-40B8-87E0-90A9AF9657B0),
helpstring("_IComExeCE11CtrlEvents Interface")
]
dispinterface _IComExeCE11CtrlEvents
{
properties:
methods:
};

[
uuid(0A9DF809-A18A-4846-AFBB-E7B26507355E),
helpstring("ComExeCE11Ctrl Class")
]
coclass ComExeCE11Ctrl
{
[default] interface IComExeCE11Ctrl;
[default, source] dispinterface _IComExeCE11CtrlEvents;
};
};
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.cpp : Implementation of WinMain

// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f ComExeCE11ps.mk in the project directory.
//----------------------------------------------------------------------------
----------------------------
#include "stdafx.h"
#include "resource.h"
#include "initguid.h"
#include "ComExeCE11.h"

#include "ComExeCE11_i.c"
#include "ComExeCE11Ctrl.h"


LONG CExeModule::Unlock()
{
LONG l = CComModule::Unlock();
if (l == 0)
{
#if _WIN32_WINNT >= 0x0400
if (CoSuspendClassObjects() == S_OK)
PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
#else
PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
#endif
}
return l;
}

CExeModule _Module;

BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_ComExeCE11Ctrl, CComExeCE11Ctrl)
END_OBJECT_MAP()


LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
{
while (*p1 != NULL)
{
LPCTSTR p = p2;
while (*p != NULL)
{
if (*p1 == *p++)
return p1+1;
}
p1++;
}
return NULL;
}

/////////////////////////////////////////////////////////////////////////////
//
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
{
lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
//HRESULT hRes = CoInitialize(NULL);
// If you are running on NT 4.0 or higher or under Windows CE you can use
the following call
// instead to make the EXE free threaded.
// This means that calls come in on a random RPC thread
HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
_ASSERTE(SUCCEEDED(hRes));
_Module.Init(ObjectMap, hInstance);
_Module.dwThreadID = GetCurrentThreadId();
TCHAR szTokens[] = _T("-/");

int nRet = 0;
BOOL bRun = TRUE;
LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
while (lpszToken != NULL)
{
if (lstrcmpi(lpszToken, _T("UnregServer"))==0)
{
_Module.UpdateRegistryFromResource(IDR_ComExeCE11, FALSE);
nRet = _Module.UnregisterServer();
bRun = FALSE;
break;
}
if (lstrcmpi(lpszToken, _T("RegServer"))==0)
{
_Module.UpdateRegistryFromResource(IDR_ComExeCE11, TRUE);
nRet = _Module.RegisterServer(TRUE);
bRun = FALSE;
break;
}
lpszToken = FindOneOf(lpszToken, szTokens);
}

if (bRun)
{
hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE);
_ASSERTE(SUCCEEDED(hRes));

MSG msg;
while (GetMessage(&msg, 0, 0, 0))
DispatchMessage(&msg);

_Module.RevokeClassObjects();
}

CoUninitialize();
return nRet;
}

//----------------------------------------------------------------------------
---------------------------
// ComExeCE11Ctrl.cpp : Implementation of CComExeCE11Ctrl
//----------------------------------------------------------------------------
---------------------------
#include "stdafx.h"
#include "ComExeCE11.h"
#include "ComExeCE11Ctrl.h"

/////////////////////////////////////////////////////////////////////////////
// CComExeCE11Ctrl


STDMETHODIMP CComExeCE11Ctrl::Function()
{
// TODO: Add your implementation code here
static int nCount = 0;
FILE *fp = NULL;

fp = fopen("\\temp\\out.txt", "a+");
if(fp != NULL)
{
fprintf(fp, "nCount = %d\r\n", nCount);
fclose(fp);
}
//AfxMessageBox(L"CComExeCE11Ctrl::Function() is called");
return S_OK;
}

STDMETHODIMP CComExeCE11Ctrl::_com_issue_errorex(HRESULT _hr1, IUnknown
*pthis1, const GUID refiid1)
{
// TODO: Add your implementation code here

return S_OK;
}

//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.res
//----------------------------------------------------------------------------
---------------------------
HKCR
{
NoRemove AppID
{
{E465FB4B-3128-4895-9A8C-23EDB7779AFE} = s 'ComExeCE11'
'ComExeCE11.EXE'
{
val AppID = s {E465FB4B-3128-4895-9A8C-23EDB7779AFE}
}
}
}
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.res
//----------------------------------------------------------------------------
---------------------------
HKCR
{
ComExeCE11.ComExeCE11Ctrl.1 = s 'ComExeCE11Ctrl Class'
{
CLSID = s '{0A9DF809-A18A-4846-AFBB-E7B26507355E}'
}
ComExeCE11.ComExeCE11Ctrl = s 'ComExeCE11Ctrl Class'
{
CLSID = s '{0A9DF809-A18A-4846-AFBB-E7B26507355E}'
CurVer = s 'ComExeCE11.ComExeCE11Ctrl.1'
}
NoRemove CLSID
{
ForceRemove {0A9DF809-A18A-4846-AFBB-E7B26507355E} = s 'ComExeCE11Ctrl
Class'
{
ProgID = s 'ComExeCE11.ComExeCE11Ctrl.1'
VersionIndependentProgID = s 'ComExeCE11.ComExeCE11Ctrl'
ForceRemove 'Programmable'
LocalServer32 = s '%MODULE%'
val AppID = s '{E465FB4B-3128-4895-9A8C-23EDB7779AFE}'
'TypeLib' = s '{4B7E4501-9B22-4D5B-8241-2E11F2B993A3}'
}
}
}
//----------------------------------------------------------------------------
---------------------------

//===================================================
// COM Client source
//----------------------------------------------------------------------------
---------------------------
// Test_ComExeCE11.cpp : Defines the entry point for the application.
//----------------------------------------------------------------------------
---------------------------
#include "stdafx.h"

#import "..\ComExeCE11\ComExeCE11.tlb" no_namespace // sta2002

int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
CLSID clsid;
IID IIDIComExeCECtrl;
HRESULT rc;
IComExeCE11Ctrl* pComCtrl;

if (CoInitializeEx(NULL, COINIT_MULTITHREADED)<0)
{
printf("CoInitializeEx() is fail\r\n");
getchar();
return -1;
}
else
{
printf("CoInitializeEx() is success\r\n");
}

rc = CLSIDFromProgID(OLESTR("ComExeCE11.ComExeCE11Ctrl.1"),&clsid);
if (FAILED(rc))
{
printf("Failure in call to CLSIDFromProgID\r\n");
getchar();
return -1;
}
else
{
printf("calling CLSIDFromProgID is success\r\n");
}
rc = IIDFromString(OLESTR("{E5DEE0DC-15C4-4EE8-AB6F-EFB9B0747B2C}"),
&IIDIComExeCECtrl);
if (FAILED(rc))
{
printf("Failure in call to IIDFromString\r\n");
getchar();
return -1;
}
else
{
printf("calling IIDFromString is success\r\n");
}

TCHAR szOutText[256] = {0,};
char chOutText[256] = {0,};

pComCtrl = NULL;

rc = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, //CLSCTX_ALL,
//CLSCTX_LOCAL_SERVER
IIDIComExeCECtrl, (void**)&pComCtrl);
if (FAILED(rc))
{
sprintf(chOutText, "Failure in call to CoCreateInstance[error = %x]", rc);
printf("%s\r\n", chOutText);
getchar();
return -1;
}
else
{
printf("calling CoCreateInstance is success\r\n");
}
getchar();
return 0;
}
------------------------------------------------------------------------------
-------------------------
Post by Paul G. Tobey [eMVP]
Then I'd say that you're asking for an interface to whatever object you've
created that the object doesn't have. Without seeing the client code, we
can't possibly guess what that might be.
Paul T.
Post by sta2002 via PocketPCJunkies.com
Additionally,
[quoted text clipped - 145 lines]
Post by sta2002 via PocketPCJunkies.com
Post by Paul G. Tobey [eMVP]
Paul T.
--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/wince-vc/201004/1
Paul G. Tobey [eMVP]
2010-04-13 03:49:31 UTC
Permalink
Verify for us what COM/DCOM options you have built into your OS.

Let's try some experiments.

A. Marshalling

1. Try a custom interface NOT DERIVED FROM IDispatch. I don't think that
IDispatch is marshalled. If I'm right about that, what you're trying to do
won't work except for an in-proc object or if you do your own marshalling.

2. Make the custom interface very simple with a single function returning an
HRESULT, as you do in Function, but taking an integer pointer as a
parameter. Have it put something that you will recognize if it comes back
correctly in the integer pointer (like 0x12345678).

3. Make sure that you have QueryInterface, etc. implemented for you by
ATL/MFC.

If no success:

B. DCOM Missing

1. Recode your object as an in-proc object in a DLL, again not inheriting
from IDispatch.

2. Changing CoCreateInstance, of course, see if you can get this to work.
This cuts marshaling out of the equation totally and should work, even if
your OS doesn't have DCOM in it.

Paul T.
Post by sta2002 via PocketPCJunkies.com
1) out of process COM server
. filename : ComExeCE11.exe
. made by a project of WCE ATL COM AppWizard (EVC++ 4.0)
2) Proxy Stub for COM server
. filename : ComExeCE11PS.dll
. made by a project of WCE Dynamic-Link Library
3) COM client
. filename : Test_ComExeCE11.exe
. made by the project of WCE Application (EVC++ 4.0)
the following source codes are on ComExeCE11.exe and Test_ComExeCE11.exe
//===================================================
// COM server source
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.idl : IDL source for ComExeCE11.dll
//
// This file will be processed by the MIDL tool to
// produce the type library (ComExeCE11.tlb) and marshalling code.
//----------------------------------------------------------------------------
---------------------------
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(E5DEE0DC-15C4-4EE8-AB6F-EFB9B0747B2C),
dual,
helpstring("IComExeCE11Ctrl Interface"),
pointer_default(unique)
]
interface IComExeCE11Ctrl : IDispatch
{
[id(1), helpstring("method Function")] HRESULT Function();
[id(2), helpstring("method _com_issue_errorex")] HRESULT
_com_issue_errorex
(HRESULT _hr1, IUnknown *pthis1, const GUID refiid1);
};
[
uuid(4B7E4501-9B22-4D5B-8241-2E11F2B993A3),
version(1.0),
helpstring("ComExeCE11 1.0 Type Library")
]
library COMEXECE11Lib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(C163B931-E486-40B8-87E0-90A9AF9657B0),
helpstring("_IComExeCE11CtrlEvents Interface")
]
dispinterface _IComExeCE11CtrlEvents
{
};
[
uuid(0A9DF809-A18A-4846-AFBB-E7B26507355E),
helpstring("ComExeCE11Ctrl Class")
]
coclass ComExeCE11Ctrl
{
[default] interface IComExeCE11Ctrl;
[default, source] dispinterface _IComExeCE11CtrlEvents;
};
};
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.cpp : Implementation of WinMain
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f ComExeCE11ps.mk in the project directory.
//----------------------------------------------------------------------------
----------------------------
#include "stdafx.h"
#include "resource.h"
#include "initguid.h"
#include "ComExeCE11.h"
#include "ComExeCE11_i.c"
#include "ComExeCE11Ctrl.h"
LONG CExeModule::Unlock()
{
LONG l = CComModule::Unlock();
if (l == 0)
{
#if _WIN32_WINNT >= 0x0400
if (CoSuspendClassObjects() == S_OK)
PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
#else
PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
#endif
}
return l;
}
CExeModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_ComExeCE11Ctrl, CComExeCE11Ctrl)
END_OBJECT_MAP()
LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
{
while (*p1 != NULL)
{
LPCTSTR p = p2;
while (*p != NULL)
{
if (*p1 == *p++)
return p1+1;
}
p1++;
}
return NULL;
}
/////////////////////////////////////////////////////////////////////////////
//
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
{
lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
//HRESULT hRes = CoInitialize(NULL);
// If you are running on NT 4.0 or higher or under Windows CE you can use
the following call
// instead to make the EXE free threaded.
// This means that calls come in on a random RPC thread
HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
_ASSERTE(SUCCEEDED(hRes));
_Module.Init(ObjectMap, hInstance);
_Module.dwThreadID = GetCurrentThreadId();
TCHAR szTokens[] = _T("-/");
int nRet = 0;
BOOL bRun = TRUE;
LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
while (lpszToken != NULL)
{
if (lstrcmpi(lpszToken, _T("UnregServer"))==0)
{
_Module.UpdateRegistryFromResource(IDR_ComExeCE11, FALSE);
nRet = _Module.UnregisterServer();
bRun = FALSE;
break;
}
if (lstrcmpi(lpszToken, _T("RegServer"))==0)
{
_Module.UpdateRegistryFromResource(IDR_ComExeCE11, TRUE);
nRet = _Module.RegisterServer(TRUE);
bRun = FALSE;
break;
}
lpszToken = FindOneOf(lpszToken, szTokens);
}
if (bRun)
{
hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE);
_ASSERTE(SUCCEEDED(hRes));
MSG msg;
while (GetMessage(&msg, 0, 0, 0))
DispatchMessage(&msg);
_Module.RevokeClassObjects();
}
CoUninitialize();
return nRet;
}
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11Ctrl.cpp : Implementation of CComExeCE11Ctrl
//----------------------------------------------------------------------------
---------------------------
#include "stdafx.h"
#include "ComExeCE11.h"
#include "ComExeCE11Ctrl.h"
/////////////////////////////////////////////////////////////////////////////
// CComExeCE11Ctrl
STDMETHODIMP CComExeCE11Ctrl::Function()
{
// TODO: Add your implementation code here
static int nCount = 0;
FILE *fp = NULL;
fp = fopen("\\temp\\out.txt", "a+");
if(fp != NULL)
{
fprintf(fp, "nCount = %d\r\n", nCount);
fclose(fp);
}
//AfxMessageBox(L"CComExeCE11Ctrl::Function() is called");
return S_OK;
}
STDMETHODIMP CComExeCE11Ctrl::_com_issue_errorex(HRESULT _hr1, IUnknown
*pthis1, const GUID refiid1)
{
// TODO: Add your implementation code here
return S_OK;
}
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.res
//----------------------------------------------------------------------------
---------------------------
HKCR
{
NoRemove AppID
{
{E465FB4B-3128-4895-9A8C-23EDB7779AFE} = s 'ComExeCE11'
'ComExeCE11.EXE'
{
val AppID = s {E465FB4B-3128-4895-9A8C-23EDB7779AFE}
}
}
}
//----------------------------------------------------------------------------
---------------------------
// ComExeCE11.res
//----------------------------------------------------------------------------
---------------------------
HKCR
{
ComExeCE11.ComExeCE11Ctrl.1 = s 'ComExeCE11Ctrl Class'
{
CLSID = s '{0A9DF809-A18A-4846-AFBB-E7B26507355E}'
}
ComExeCE11.ComExeCE11Ctrl = s 'ComExeCE11Ctrl Class'
{
CLSID = s '{0A9DF809-A18A-4846-AFBB-E7B26507355E}'
CurVer = s 'ComExeCE11.ComExeCE11Ctrl.1'
}
NoRemove CLSID
{
ForceRemove {0A9DF809-A18A-4846-AFBB-E7B26507355E} = s 'ComExeCE11Ctrl
Class'
{
ProgID = s 'ComExeCE11.ComExeCE11Ctrl.1'
VersionIndependentProgID = s 'ComExeCE11.ComExeCE11Ctrl'
ForceRemove 'Programmable'
LocalServer32 = s '%MODULE%'
val AppID = s '{E465FB4B-3128-4895-9A8C-23EDB7779AFE}'
'TypeLib' = s '{4B7E4501-9B22-4D5B-8241-2E11F2B993A3}'
}
}
}
//----------------------------------------------------------------------------
---------------------------
//===================================================
// COM Client source
//----------------------------------------------------------------------------
---------------------------
// Test_ComExeCE11.cpp : Defines the entry point for the application.
//----------------------------------------------------------------------------
---------------------------
#include "stdafx.h"
#import "..\ComExeCE11\ComExeCE11.tlb" no_namespace // sta2002
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
CLSID clsid;
IID IIDIComExeCECtrl;
HRESULT rc;
IComExeCE11Ctrl* pComCtrl;
if (CoInitializeEx(NULL, COINIT_MULTITHREADED)<0)
{
printf("CoInitializeEx() is fail\r\n");
getchar();
return -1;
}
else
{
printf("CoInitializeEx() is success\r\n");
}
rc = CLSIDFromProgID(OLESTR("ComExeCE11.ComExeCE11Ctrl.1"),&clsid);
if (FAILED(rc))
{
printf("Failure in call to CLSIDFromProgID\r\n");
getchar();
return -1;
}
else
{
printf("calling CLSIDFromProgID is success\r\n");
}
rc = IIDFromString(OLESTR("{E5DEE0DC-15C4-4EE8-AB6F-EFB9B0747B2C}"),
&IIDIComExeCECtrl);
if (FAILED(rc))
{
printf("Failure in call to IIDFromString\r\n");
getchar();
return -1;
}
else
{
printf("calling IIDFromString is success\r\n");
}
TCHAR szOutText[256] = {0,};
char chOutText[256] = {0,};
pComCtrl = NULL;
rc = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, //CLSCTX_ALL,
//CLSCTX_LOCAL_SERVER
IIDIComExeCECtrl, (void**)&pComCtrl);
if (FAILED(rc))
{
sprintf(chOutText, "Failure in call to CoCreateInstance[error = %x]", rc);
printf("%s\r\n", chOutText);
getchar();
return -1;
}
else
{
printf("calling CoCreateInstance is success\r\n");
}
getchar();
return 0;
}
------------------------------------------------------------------------------
-------------------------
Post by Paul G. Tobey [eMVP]
Then I'd say that you're asking for an interface to whatever object you've
created that the object doesn't have. Without seeing the client code, we
can't possibly guess what that might be.
Paul T.
Post by sta2002 via PocketPCJunkies.com
Additionally,
[quoted text clipped - 145 lines]
Post by sta2002 via PocketPCJunkies.com
Post by Paul G. Tobey [eMVP]
Paul T.
--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/wince-vc/201004/1
sta2002 via PocketPCJunkies.com
2010-04-14 03:00:46 UTC
Permalink
Hi Paul.

I've took a test such things that I had the procedure on another mobile
device.
There was no any problems. It is complete to be worked between COM server(out
of process) and COM client(c#, mfc and win32).

I think that the OS image on the mobile device doesn't support COM/DCOM.
so, I asked for new OS image that is available to support COM/DCOM.

I'm happy that I've finally solve the problem.

I sincerely appreciate everything that you helped solve it.
Post by Paul G. Tobey [eMVP]
Verify for us what COM/DCOM options you have built into your OS.
Let's try some experiments.
A. Marshalling
1. Try a custom interface NOT DERIVED FROM IDispatch. I don't think that
IDispatch is marshalled. If I'm right about that, what you're trying to do
won't work except for an in-proc object or if you do your own marshalling.
2. Make the custom interface very simple with a single function returning an
HRESULT, as you do in Function, but taking an integer pointer as a
parameter. Have it put something that you will recognize if it comes back
correctly in the integer pointer (like 0x12345678).
3. Make sure that you have QueryInterface, etc. implemented for you by
ATL/MFC.
B. DCOM Missing
1. Recode your object as an in-proc object in a DLL, again not inheriting
from IDispatch.
2. Changing CoCreateInstance, of course, see if you can get this to work.
This cuts marshaling out of the equation totally and should work, even if
your OS doesn't have DCOM in it.
Paul T.
Post by sta2002 via PocketPCJunkies.com
1) out of process COM server
. filename : ComExeCE11.exe
[quoted text clipped - 353 lines]
Post by sta2002 via PocketPCJunkies.com
Post by Paul G. Tobey [eMVP]
Paul T.
--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/wince-vc/201004/1
Loading...