|
Brian,
Thanks for posting your tutorial series. Using your code I was able to build the hello world sample and to start the DCOM learning curve.
One of the things that I am interested in doing is to put the DCOM functionality inside of an ActiveX control. Ideally, this control would be able to commmunicate with different intranet servers at a client's site. Seemed pretty simple since you had done all of the hard work already.
But it's never simple is it. My ActiveX control which is essentially you HelloWorld application with an MFC ActiveX wrapper connects to the server OK but the AfxConnectionAdvise() fails with error code 1008. This translates to "An attempt was made to reference a token that does not exist." Well, duh, that was not very helpful.
Hacker that I am, I went into the server and using DCOMCNFG.EXE, removed all security from the HelloWorld service. Basically "Everyone" can have there way with HelloWorld.
This did not fix the AfxConnectionAdvise() problem however.
Anyone, have any ideas on this one?
Thanks.
|
|
|
|
|
I have exactly the same problem as you had.
I created ActiveX control which runs on client side and communicates with object on our web server.
Did someone find out how to resolve this problem?
Or maybe Brian has a clue?
|
|
|
|
|
I know that AfxConnectionAdvise() does fail inside of ActiveX controls; I think it has something to do with the fact that, as far as DCOM is concerned, ActiveX controls do not really have the same kind of proxy-stub functionality that "real" servers do, and so as far as I know can only communicate one way using DCOM.
If anybody else has any other info that would be great!! No, I really don't have a clue about this one, since I don't work with writing ActiveX controls.
Cheers,
Brian Hart
|
|
|
|
|
I thought I was very careful when following the instructions. I must have made an error at some point. Whe I build at step 6 I get the following errors.
--------------------Configuration: HelloServ - Win32 Release MinDependency--------------------
Compiling...
HelloWorld.cpp
C:\test\HelloServ\HelloWorld.cpp(22) : error C2065: '_lpa' : undeclared identifier
C:\test\HelloServ\HelloWorld.cpp(22) : error C2440: '=' : cannot convert from 'char [16]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\test\HelloServ\HelloWorld.cpp(22) : error C2065: '_convert' : undeclared identifier
Error executing cl.exe.
HelloServ.exe - 3 error(s), 0 warning(s)
Any idea what I may have missed?
Thanks,
Rick Crone
rick.crone@wth.ord
|
|
|
|
|
Rick,
I think you forgot the USES_CONVERSION macro that should be the first line inside your method.
|
|
|
|
|
i has a change server address 200.xx.xx.xx on different network pc
also connect fair
how i get work it?
teacher please tell me how to............
thank you in advance document
|
|
|
|
|
i has a change server address 200.xx.xx.xx on different network pc
also connect fair
how i get work it?
teacher please tell me how to............
thank you in advance document
|
|
|
|
|
If you want to use a new server, make sure to install the HelloServ.exe and HelloServps.dll files on it, and see Step 6 for how to do that.
Then, in the client code, in CHelloCliDlg::OnStartServer(), go to where we fill in the COSERVERINFO structure. See the line:
serverInfo.pwszName = ?
Fill that in with whatever the IP address is like so:
serverInfo.pwszName = L"200.xxx.xxx.xxx"; , but make sure to put the actual numbers in the IP address from the 'x's.
Also, please submit your question only once I will get back to you, don't worry
|
|
|
|
|
i has a change server address 200.xx.xx.xx on different network pc
also connect fair
how i get work it?
teacher please tell me how to............
thank you in advance document
|
|
|
|
|
Hi
Since you're the author of COM/DCOM Tutorial, I would like to ask you a question. How can I fire an event to multiple clients?
Thanks
|
|
|
|
|
If multiple clients advise themselves with the server, the code that the Wizards generate (the 'CProxyDHelloWorldEvents' class) already takes care of that.
In effect, the Fire_OnSayHello() function, as you can see in the HelloServCP.h file, runs a little for( ) loop to call all the clients that have Advised() the server. If multiple clients Advise the server, then when the server fires an event (by calling Fire_OnSayHello( )), all clients will receive the event.
Try this:
1. Put the server (the HelloServ.exe and HelloServps.dll files) on the server machine,
and then copy the client program to more than one machine. Also, don't forget to put the HelloServps.dll file on each client machine and register the DLL on both machines. In fact, you need to copy HelloServ.exe to both and register it on both, because otherwise AfxConnectionAdvise() will fail.
2. Click the Start Server and Advise Server button on both, and then click the Call Method button on one of them... I would be interested in hearing about what happens!
Bria
|
|
|
|
|
When I Click the "Start Server" button, I got a message
saying "Unable to access IHelloWorld because Class not Registered",. I am creating the server locally, by un-comment the this line /*HRESULT hResult = m_pHelloWorld->CreateInstance(CLSID_HelloWorld) */
I did registered the HelloServ.dll with regsrv32.exe. I would be greate if you can let me know what could cause this problem.
Thanks in advance.
Camso
|
|
|
|
|
You also need to run 'HelloServ /RegServer' on your local machine in order for local creation to work. See Step 6 for more details.
1. Run 'HelloServ /RegServer'
2. Run 'regsvr32 HelloServps.dll'
And voila! Let me know if you continue to experience problems.
|
|
|
|
|
Hello readers...
I have received questions from people and I wonder if you are starting from the beginning and working through the tutorial. I provide detailed (I hope ) guidance to you throughout the tutorial, and we go through the process in a step-by-step manner, so as a tip, I suggest that you start out at Step 1 before you post and tell me my tutorial doesn't work or you don't understand it.
Brian Har
|
|
|
|
|
You don't state what the readers should already know in order to follow all this (ATL, COM, MFC's COM, etc.)
Playing around with wizards really doesn't accomplish much when it comes to something as complicated as COM/DCOM. You really should do much more explaining. Sadly, your tutorial is typical of many computer books. At least your stuff is free!
Since many folks don't have two computers, you should explain how to configure this as a local server. This is a good debugging technique anyway.
I was unable to get steps 6 & 7 working on a single machine, and I don't have time for debugging. Your description of step 7 leaves out ALOT of the steps needed
to recreate the client code, so it has to be copied from the zip file.
I would've used ATL's implmentation of connection points on both the client and server. Its more consistent and understandable
|
|
|
|
|
Steve,
Thanks for getting back to me! If you look on Step 1, I do explain what you need to know to follow the tutorial, and I do my best to explain things where appropriate (see Step 5 for Connection Points). I like to think that sometimes we need a I-don't-care-how-this-works-just-how-do-I-do-this tutorial for complex things like DCOM, kind of like the remote control.
I do appreciate your suggestion about making the tutorial more comprehensive and accounting for different reader configurations. I plan to write other, more comprehensive tutorials as things progress along. I know you're frustrated because of what I do have and things not working, and I want to do my best to fix this Please bear with me -- using the Visual C++ wizards is something alot of people just starting out are comfortable with, too, so that's why I used this approach. Step 7 does need to be more comprehensive, though, I agree.
Watch for updates!! And try to begin this tutorial on the first step, Step 1, if you haven't. It's something that I always recommend
Plus, about using ATL's implementation of Connection points -- they're an option, but Microsoft didn't explain how to use them without putting a lot of docuemntation to wade through in my face Plus, Connection Points in ATL don't actually work consistently, whereas the MFC implementation is a little more robust
Cheers,
Brian Har
|
|
|
|
|
Ya, I went through all the steps, but based on the meager descriptions, it seems readers were expected to know than what you listed in Step1.
I'm sure you know there's lots of example code & wizard tutorials on the web, what's lacking is good descriptions of the technologies that don't mimic MSDN. There are also tools that can be discussed to help beginners get a better understanding & fix problems (RegEdit, the Services Control Panel applet, etc.).
The wizard issue is really one of philosophy. If, under blue sky conditions, the tutorial does exactly what someone needs - GREAT! If, however, slight changes need to be made or someone makes a small mistake that somehow compiles, there could be alot of frustration.
I've been using both MFC's & ATL's implementations of connection points for several years, and I prefer ATL's. I don't know of anyone who prefers MFC, except for those I-don't-want-to-learn-the-basics-of-COM types (wizard people). Wizards per se are OK, but only with some understanding of what they're doing.
Actually, the whole event thing changes with COM+, but that's another tutorial!
|
|
|
|
|
Steve,
Don't knock the Wizards, man!
Seriously, though, I totally agree with you on many levels, and I think you make some very valid points. Especially that, no, this tutorial doesn't do crap! But that's not the point. The point is to teach by trivial example; if you have your hand held to do something simple, chances are it makes doing something else that's more complicated a little less daunting.
I'm not stopping you from writing your own tutorial if you think you have a different if not better approach. In fact, I wouldn't miss it for all the tea in China! (Apologies to Chinese readers of this site) By all means, explain to us, Great Guru...
It's just that, I spent time out of my work schedule and life to write the tutorial... And tutorials are not around to do 'exactly what people need' anyway... they teach, (hopefully) or they don't.
Please note that I didn't have to post anything at all on The Code Project and could have saved time maybe... This tutorial's purpose never was to show you why or how DCOM/COM/ATL works, but just to do the most simple procedure I could think of so people can have chances to 'get their feet wet' as it were...
Of course you don't need the Wizards, but for some of the enormous amounts of code that one has to write and that you have to do some of it every time regardless of the software you're writing, they do save some typing and leave to worry about what you're going to write instead of how to write it...
But seriously, why make things unnecessarily hard and go to effort that you don't have to go to when there are tools that make it easier and faster to meet your deadlines (and maybe even, shudder, impress one's boss...).
"If someone makes a small mistake or there are changes in the code that somehow compiles, there can be a lot of frustration," Whoever said frustration wasn't a natural part of programming?? Plus, to address your point about "Wizards are OK, but only with some understanding of what you're doing," That's a valid point and I totally agree Don't you see? If I can just use wizards to write the framework for me, fill in the details, and voila!, working program in two weeks instead of spending one month or more on the learning curve and then coding everything from scratch, you can guess which route I'm going to take
If someone had posted this tutorial up earlier this summer than I did, I probably could have gotten way more done in less time by just having the educational experience of doing these basic steps... by doing this one learns more in less time and even gains understanding!
But hey, we could bandy this back and forth forever like the whole Windows vs. UNIX/LINUX/KOBOL (and COBOL) debate.
You program with what you prefer, and I'll program with what I prefer, and let's call it Pax, OK?
Plus, how about, since you champion ATL's implementation of connection points so much, then write up a similar tutorial that implements the same "Hello World" client and server but with more ATL than MFC... Because to tell truth, I am stumped by the ATL way, and if you have insight I definitely think that would be useful to not only me but also other readers of The Code Project.
C'mon, explain to us how it should be done; no one's stopping you!! However, no crapping on my work -- if you have criticisms be fair and constructive with your words. It doesn't look good to stomp all over someone else's work... But I can take appropriately and diplomatically worded criticisms...
Sincerely Yours,
Brian Har
|
|
|
|
|
I would like to say many THNX to Brian. I didn't had a lot of time to learn DCOM, but this example helped me to finish my job in time.
|
|
|
|
|
There are always different ways to reach a goal.
I.e. you can take the pony express or an airplane.
For me it would be the plane (wizards!!!), but why
not letting others use the good old pony express.
Thanx for your great tutorial.
|
|
|
|
|
Steven,
I too would like to see this implemented in ATL. Please write a similar article using ATL instead so we can all learn. It would be especially nice to include why the ATL is better than the MFC implementation.
Thanks,
Ed Evans
|
|
|
|
|
Another vote for the ATL based copy of this tutorial.
Cheers,
Milan
|
|
|
|
|
It seems to be a nice learning while reading this article.
How can I use it on windows98,I do have Visual Studio6
,DCOMCNFG.EXE,ATL.Please do reply fast.thank
|
|
|
|
|
Microsoft has a patch for Windows 98/95 called DCOM98. I say in the article that you can get this at the Microsoft site, at http://www.microsoft.com/com/.
Look for a "DCOM98" folder or file with the Find File command on the Start menu, and then install that puppy.
Cheers,
Brian Har
|
|
|
|
|
Please note that in Step 1 I tell you what this tutorial assumes:
+ ...
+ ...
+ That you're developing all this on Windows NT 4.0 or higher
Give the Microsoft DCOM98 extensions a try and see if they work. Check out http://www.microsoft.com/com/ for more, too.
Cheers, Bria
|
|
|
|
|