|
I want to know how to implement custom marshaling between machine and machine.but I can't find even one example anywhere.Can you offer me one?
Bill
Thank you all for your help!
|
|
|
|
|
Maybe this question is same to the last .Could anyone explain it to me?
::CoInitialize(NULL);
ISomeInterfacePtr ppv;
ppv.CreateInstance("MYSERVER.SOMEINTERFACE.1");
ppv->SomeFunction();
The code can be successful if the com object is in a dll .But failed
when the com object is in the exe-server .
I used ATL to create the exe-server project . Do I need to add additional
codes if it is created as an exe?
|
|
|
|
|
What is the error code when the object is in the exe-server? Did you register the proxy/stub for the exe server?
|
|
|
|
|
Thanks a lot . As I have no materials at hand now, I don't know what the error code means,which is a negative number .
But what do you mean that the proxy/stub need to be registered ?
After I compile and link the source code , the VC has helped me to register the exe-server .
I tried to create a dual interface in this Atl project ,and I found that I can use it in the client code . But if the interface was an custom interface which means it inherits from the IUnknown ,not IDispatch , I found the problem I posted last time .
Why?
|
|
|
|
|
For dual interfaces COM can use Automation(aka Unversal) marshaller and there is no need for separate proxy/stub dll. If you have custom interfaces and expect to the marshalling to be envolved (call the object methods from another apartment, in case of out-of-proc object this is always true), than you need to build and register proxy/stub dll. IDL compiler generates all necessary files for that and ATL wizard creates .def & makefile to build it (<yor projectname="">ps.def and <youprojectname>ps.mk.
Edward
|
|
|
|
|
If selected to create a custom interface, you'll need to register the proxy server marshalling dll for your EXE COM server. Look at the file with the WinMain(), Unlock(), and Monitor() functions that SCM uses to startup your COM server. At the top of the file you'll see some comments that look like this:
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f [Your EXE name here]ps.mk in the project directory.
Just do what it says. (NOTE: You may need to run vcvars32.bat in your VC directory to setup the paths to nmake and stuff.) After doing that you should have a proxy/server marshalling DLL file. You'll also need to register the DLL: regsvr32 [The newly created proxy/server]ps.dll
A way to automate this is to put it in your Project | Settings under the "Post-Build Step":
nmake /f MyComponent.mk
regsvr32 /c /s MyComponenetps.dll
- Pros
|
|
|
|
|
when I added the custom event in the dll-server ,which means the event interface inherits from IUnknown ,I can Advise using Sink-Object from the client code . But when the server is exe , Advise failed from the client code .Why?
|
|
|
|
|
In one of my articles I wrote how we can use a VB activex dll component in a VC app. The problem is that when I try to create the component from a new thread, everything bonks. Is this a threading problem? I think my activex dll is apartment threaded(STA) whereas I wanna use it in an MTA. Hence the problem.... So what's the solution? Maybe I can use an activex exe cause it runs in it's own thread..
Any comments/help is welcome.
TIA.
Hush..Hush.. thought I heard you calling my name now...
|
|
|
|
|
Gidday (dead give-away where I live) .. Im pretty new at
this so dont shout too loud if I mess up..
Anyway - I have an NT Service, based on service generated by
the ATL wizard (VC++ 6.0). The Service will install on NT 4.0 Workstation,
NT 4.0 Enterprise Server 64 bit encryption.
It wont however install on NT 4.0 Enterprise Server 128 bit
encryption - the UpdateRegistryFromResource call appears to
fail in the CserviceModule::RegisterServer code, but its
real hard to figure out what the error means ... 'Class not
registered' - I have used "service.exe /regserver"
Just a thought Im having, is, should I install VC++ on the
new platform (Its installed on a 64 bit encryption platform)
compile and generate the code with a new GUID ???
Has anyone else got any ideas, short of pulling off that
128 bit encryption version of NT Server, and installing
a 64 bit version ?? (this appears to be the only real
difference in the machines...)
Garth Lancaster
g.lancaster@mbf.com.au
|
|
|
|
|
'bugger' - I just realised that our e-mail system will be
down till 5pm Saturday Australia time (=18 to 22 hours
ahead of the states) .. snigger - this means that you cant
flame me directly - as you might tell, my Net experiences
havent been great so far - there are more people out there
interested in nit-pickin and flaming than there are in helping,
imho
In the meantime, Im going to install Visual Studio Pro on the
NT Server with the Enterprise Server 4.0 128 Bit encryption
version on it, build a nothing ATL COM Service with the
wizard, and see if that works ..
'G'
G J Lancaster
|
|
|
|
|
Almost the end of the saga .. after installing VC++ on the
NT Server (4.0 Enterprise, 128 bit encryption), I generated
the same dummy ATL_Service using the wizard ... and it
installed and ran .. so then I tried the original
service that wouldnt install.. and lo and behold it worked,
too..
so Im almost happy .. I say almost, because I still really
do know what went on here, and why installing VC++ fixed it.
If anyone out there has been watching this, and knows the
answer, please put me out of my (semi) misery
regards from 'Down Under'
Garth
|
|
|
|
|
If you didn't specify _ATL_STATIC_REGISTRY atl will try to use "Registrar" component to register your server and probably this component was not installed on your server.
Edward
|
|
|
|
|
Thanks Edward ... If Id have known that on Saturday, I would
have had an easier time
CUL, Garth
|
|
|
|
|
Hello all the ATL/COM/C++ gurus!!!
The little and unnoticed ATL beginner desparately needs your help.
I am trying to build my project with ReleaseMinSize configuration with _ATL_MIN_CRT flag.
Note that I don't have any runtime header files included, but I use #import-ed VB-based COM objects.
Note that I disabled "exception handling" mechanisms and MFC support.
All data types I am using are _com_ptr_t, _bstr_t, _variant_t from import-created .tlh and .tli files, plus regular C/C++ scalar types.
My problem: link error 2001 with the bunch of unresolved external symbols.
Does anyone know where the problem is.
BIG TIME thanks to all with the BIG heart.
Kirill.
|
|
|
|
|
Those xxx_t types are provided by the C runtime library (CRT). Defining _ATL_MIN_CRT means your binary doesn't link with the CRT. Since your code needs the CRT, you get an unresolved symbol. Remove the _ATL_MIN_CRT symbol to fix this.
The help page on LNK2001 has more info.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
If possible, you may also use raw_interfaces_only and raw_native_types with your #import directive, then subsitute _com_ptr_t, _bstr_t, _variant_t with CComPtr/CComQIPtr, CComBSTR and CComVariant.
|
|
|
|
|
Thanks Felix. This will definitely raise me from ATL HELL.
The problem with those #import's - lack of documentation and examples.
I only understood no_namespace, rename_namespace, rename and named_guids (the easiest ones).
All other flags had been complete mystery.
Kirill.
|
|
|
|
|
Mike, thanks for an assurance!!!
I knew that this issue was related to .tlh and .tli files, but could not put a period after my speculations.
Kirill
|
|
|
|
|
Hello,
I am looking for a way to add menu items and toolbar bitmaps through registration of a COM object and using component categories.
I have seen the "WordPad snap-in" sample in MSDN and the interfaces defined here pass HMODULE's to the main application so it can load directly from the dlls resources (specically bitmaps/strings and menus)
I have a problem and a question.
1.) I get error on MIDL(MIDL2139) compiler because HMODULE is of type void or void*...
2.) Should COM objects do this sort of thing? or should all resource items be stored in a main application - this kindof defeats the object of me designing my app + "snap-ins" to make adding functionality a question of simply registering a dll.....
If anyone can show me an example of how this sort of thing can be done
or any pointers you can give me that would be great.
thanks
|
|
|
|
|
hi i hve requirements in UK on VC++ with MFC/COM in telecome and embeded systems with 2.5 years exp. and also on GSM. if aou ar ethe on esen dyour cv to naidumg@yahoo.com
Mohan
|
|
|
|
|
Sorry guys I'm pretty new to ATL and COM stuff. The project is a shell extension with MFC support. Been looking at the tutorials on it over and over but can't find out how to fix this problem. After starting a new project I can get it to work. Then after compiling a few times (changing nothing) it ends up giving this link error. It starts happening randomly but never goes away once I first get it.
Linking...
mfcs42.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj)
mfcs42.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj); second definition ignored
Creating library ReleaseMinSize/program.lib and object ReleaseMinSize/program.exp
ReleaseMinSize/program.dll : fatal error LNK1169: one or more multiply defined symbols found
I can start a new project, transplant the code, and have it working for a while till I get this again. I've had to include afxcmn.h, and change my .cpp files to automatic use of precompiled headers. But apart from that I've not really changed anything. I can get the code to work fine in a nonMFC dll (without using MFC components). Removing all MFC statements I've added doesn't help either.
Any idea on how to fix this?
Thanks
-Neil
|
|
|
|
|
Got the similar problem with MSVCRT.lib myself except my project does not link at all ;(
I hope this one helps you:
Look at your Project Settings -> "C/C++" tab -> "category" combo -> drop "category" combo to "Preprocessor" ->
-> look at "Preprocessor definitions:" edit box. If you find _ATL_MIN_CRT, remove it for all project configurations except "Debug".
This flag tells compiler not to link your project with any Microsoft Standard Runtime Libs (for minimum size).
If you include "MFC support", MFC requires those runtimes linked to your project - that's where collision occurs.
Since you don't have any problems while MFC's presence is disabled, that sounds like my case.
Kirill.
|
|
|
|
|
Thanks for the reply.
I haven't got _ATL_MIN_CRT in my preprocessor definitions it seems. This is what I have:
WIN32,NDEBUG,_WINDOWS,_WINDLL,_AFXDLL,_MBCS,_USRDLL,_ATL_DLL
Removing _ATL_DLL doesn't seem to help. Removing _AFXDLL creates more errors ofcourse.
The strange thing is I can link the project after creating a new one, and notice no differences in any project settings after it starts having this link error.
I've tried deleting some different generated files but that hasn't helped so far either.
Any ideas?
Thanks
|
|
|
|
|
Sorry guys, fixed it now. I was using memset and including memory.h in one of my classes which seemed to cause it. Although I could comment out the memset and include statements, build it, uncomment them and build again and then it'd work. Although gives a warning:
LINK : warning LNK4089: all references to "MSVCIRT.dll" discarded by /OPT:REF
Which is good I guess. Can't see any options or flags that may have changed to cause this though.
|
|
|
|
|
Hello,
I am new to COM/ATL programming and have a question.
If I want to inherit one interface from another I have previously written (e.g. IB : IA ) do I need to implement all of IA's methods in IB? if so is there any way I can use some technique that allows you to just directly call the IA method instead of having to re-write (as in C++).
Thanks.
Paul.
|
|
|
|