|
I ran into this and found my post build steps have vanished for some unknown reason... If you don't rebuild the HelloServps.dll after adding the method, you can register the dll a million times without having the proper interface. Note that it's possible that no error message comes up on build, if you should mistype one line.
|
|
|
|
|
Hello!
I would like to run with COM+ an application on another PC. But if after some time the PC is disconnected to the network it is difficult to uninitialize the component. So i ping the controller on the network and if it is disconnected i will run a "modified" uninitialization.
But problem is, when i call "interface".Release() it takes up to 50 seconds if COM+ Runtime realizes that the rpc-server is unavailable and returns from Release-function.
What can i do???
Are SmartPointers a problem???
Thanks for all help.
Greetings harkan
|
|
|
|
|
harkan wrote:
I would like to run with COM+
Are you referring to DCOM? COM+ and DCOM are two very different techs.
harkan wrote:
when i call "interface".Release() it takes up to 50 seconds
Try simply having your program get rid of the interface pointer without trying to call release. That is, don't call release upon detecting that the connection was broken, but just show an error. Dispose of the smart pointer through delete or just let it go out of scope. If you are using smart pointers, the smart pointer will cleanup for you.
DCOM is kind of brain-dead this way.
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
Hello Everyone.,
For broadcasting purpose (Pushing a Stream to a Windows Media Server) , I necessarily have to connect to the Media Server and create an object in there prior to start my broadcasting using DCOM . I tried with the following code ..
-----------------------------------------------------------------
CString m_strServerName = "ServerName" ;
CString m_strPublishPoint1 = "publishpointName" ; //Used for Broadcasting
ZeroMemory(&cs, sizeof(cs));
cs.pwszName = m_strServerName.AllocSysString();
cs.pAuthInfo = NULL;
// Create a MULTI_QI structure to hold an IUnknown pointer
// to an IWMSServer interface.
ZeroMemory(&mqi, sizeof(mqi));
mqi.pIID = &IID_IWMSServer;
mqi.pItf = NULL;
mqi.hr = 0;
// Retrieve a pointer to the IWMSServer interface.
hr = CoCreateInstanceEx(CLSID_WMSServer,NULL,CLSCTX_LOCAL_SERVER |CLSCTX_REMOTE_SERVER,&cs,1,&mqi);
if (FAILED(hr))
{
return hr;
}
// The MULTI_QI structure contains an IUnknown pointer. Call
// QueryInterface to retrieve a pointer to IWMSServer.
hr = mqi.pItf->QueryInterface(IID_IWMSServer,(void**) &pRemoteServer);
---------------------------------------------------
I get "RPC server unavailable" .
Server is Windows 2003 and remote one.If I connect to a server locally or to an independent IP in the same network , it successfully connect . But, if the server is remote and in different network I get "RPC server is unavailable" . Could someone send some hints or solutions ..which is greatly needed.
Thanks in Advance..!
Best Regards,
Nick.
|
|
|
|
|
newnick wrote:
Server is Windows 2003 and remote one.
Make sure you put the fully-qualified UNC pathname to the server machine, including the remote netowrk if possible, into the m_strServerName variable. Make sure to escape the backslashes.
If that doesn't work, try specifying the remote server's IP address, .e.
<br />
m_strServerName = "128.200.192.1";<br />
serverInfo.pwszName = m_strServerName.AllocSysString();<br />
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
Thanks a lot Brian for your reply..!
I have specified the IP address as the server name . But still , it doesn't work.. Could you please tell me the Remote server side DCONFIG settings to be done or any thing extra..?
Thank u again Brian..!
Warm Regards,
Nick.
|
|
|
|
|
Verify that the Server program is correctly installed and registered on the remote host.
Also verify that you can, e.g., open up 'cmd' and 'ping' the IP address you are providing, where you are running ping on the client computer. Of course, you will get RPC Server Unavailable if the machine you are connecting to cannot be reached over the network at all. Double-check your network settings on both the client and remote machines. Make sure both can see each other.
1. Re-build the server, and make sure it also re-builds the Proxy-Stub DLL.
2. Copy both server and proxy-stub dll to a dir on the remote server.
3. Click Start, click Run, and then type
<server-exe-path> /Service
4. Repeat, and type in the Run box now:
regsvr32 Serverps.dll
where Serverps.dll is the name of your proxy-stub DLL produced during the build.
Also, open up DCOMCNFG on the server machine, and click on the second tab in the main box. Make sure both the checkboxes on the top of the tab are checked. Also, make sure the first drop down is set to 'Connect' and the second to 'Impersonate'. Make sure the DCOMCNFG settings on the client computer match those on the server.
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
How to Re-build the server..?
|
|
|
|
|
Look up the "Rebuild All" command in the Visual C++ docs...
Download the Step 6 files, unpack the ZIP, and then open VC++, click File, click Open Workspace, browse to the project file, click Open, click the Build menu, click Rebuild All.
|
|
|
|
|
Hey Man..! Are you serious.? Is your suggestion same to Re-build the Server.? Think deeply...
|
|
|
|
|
Sorry -- I can't help you further -- it's too complicated to do over the Internet. I think I know what's happening, but I would need to see the computers in action to be sure...
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
Never mind Brian..!
If you want , I could provide you my server IP address and password.. plz let me know your personal ID..
Thanks & Regards!
Nick.
|
|
|
|
|
I had same rpc problem. How to solve it?
jianjing qin
|
|
|
|
|
Ms brian
i want to add a method with some parameters!!!
I want add a method like this:
HResult getinfo([in]TCHAR flag,[in]long size,[out]BSTR * bstr,[out]BSTR *cstr);
what should i do when i define the interface and dispinterface method;???
in my program i define like this:
HResult getinfo([in]TCHAR flag,[in]long size,[out]BSTR * bstr,[out]BSTR *cstr);
HResult Fire_Ongetinfo([out]BSTR bstr,[out]BSTR cstr);
but i could get the result???what can i do
thank you in the advanced;
good lucky every body
|
|
|
|
|
Dear Brian
First of all, thanks for the wonderful tutorial u have here and the replies u gave me before.
I have a wierd problem here. I used your code in my program which essentially contains a method which starts the DCOM server, call the DCOM method and finally closes the DCOM server.(I did not use connection points though...) This works perfectly fine, EXCEPT that after a time lapse of about 6-7 seconds, I have to run e.g:"DCOMService /Service" again if I were to call this method repeatedly. However, this problem does not occur if I call this method repeatedly without a time lapse greater than 5-6 sec.
Would gladly appreciate if you could enlighten me on this. Thanks!
|
|
|
|
|
Hi all,
I want to know the way to notify client from server.
I tried to use PostMessage but it didn't work
|
|
|
|
|
Nguyen Duc Thang wrote:
I want to know the way to notify client from server.
I tried to use PostMessage but it didn't work
The way a client is sent events is through Connection Points. Please see the following Steps of this tutorial, in order, for more info. Work through them, don't just "read Shakespeare."
Step 5: http://www.codeproject.com/com/HelloTutorial5.asp[^]
Step 6: http://www.codeproject.com/com/HelloTutorial6.asp[^]
Step 7: http://www.codeproject.com/com/HelloTutorial7.asp[^]
There is no known way to fire events without a method being called. There is also no known way for the server to simulcast events.
You'll have to jury-rig something up which mimics that functionality.
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
while I implement the SayHello(BSTR ps) on server side, I found the ps is wide char format. but while I implement the onSayHello on clent, and define the event Func like :
DISP_FUNCTION(CHelloWorldEvents, "SayHello", OnSayHello, VT_EMPTY,VTS_BSTR )
void CHelloWorldEvents::OnSayHello(BSTR lpszHost)
it pass me a string in single char format, even I call Fire_OnSayHello(T2OLE(str)) on serverside. I have to define
DISP_FUNCTION(CHelloWorldEvents, "SayHello", OnSayHello, VT_EMPTY,VTS_WBSTR ) to get a wide char format,
why it is different while transfer from c->s than s->c
|
|
|
|
|
Hi,
I'm a beginer in DCOM programming and I did the whole tutorial but when starting server thru client dialog, this message appears in a message box "Unable to access IHelloWorld because Classe non inscrite".
I used DCOMcnfg.exe to configure TCP/IP as standard prototocol as luenii proposed but nothing happens.
Help please !
tkp
|
|
|
|
|
|
I have a case where one VB client would like to call multiple DCOM servers. In fact they will be identical DCOM servers but running on different locations (PCs). How can I call them from my application if obviously they have the same name ?
|
|
|
|
|
sdaymond wrote:
I have a case where one VB client would like to call multiple DCOM servers. In fact they will be identical DCOM servers but running on different locations (PCs). How can I call them from my application if obviously they have the same name ?
With DCOM, you tell VB what machine to instantiate an object on as well as its ProgID.
Go to Step 7[^] of the tutorial, and look for the line
serverInfo.pwszName = L"\\\\Viz-06";
in Listing 13. You replace "\\\\Viz-06" (for the UNC pathname \\Viz-06) with an Internet address, either IP or like "codeproject.com", or an UNC (i.e. \\Machine) pathname to the machine you want.
This is a little problematic to do from visual Basic, but there must be another parameter to CreateInstance() that let's you tell it the machine name. Look it up in the docs, or try to find a CreateInstanceEx() subroutine.
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
Hello Brian,
Thank you for your comment - that put me in the right direction. There is no doubt I have to create object dynamically in VB. For that purpose VB has CreateObject but with CreateObject you cannot specify remote machine. So there must be some other way.
I have done some search on the Web and found an article that directly appears to solve my problem:
"Creating Remote DCOM Objects on Specific Servers" (http://www.avdf.com/apr98/art_vb005.html)
The author - Jim Karabatsos - provides VB code for a function: CreateRemoteObject (that calls a couple of API functions, including CoCreateInstanceEx):
The code is below.
Best regards,
Stan Daymond
London, UK
Private Type SERVER_STRUCTURE
reserved1 As Long
pServer As Long
AuthInfo As Long
reserved2 As Long
End Type
Private Type MULTI_QI
pIID As Long
pInterface As Object
hResult As Long
End Type
Private Declare Function CLSIDFromProgID Lib "ole32.dll" _
(Progid As Any, Clsid As Any) As Long
Private Declare Function OleInitialize Lib "ole32.dll" _
(ByVal Nullptr As Long) As Long
Private Declare Function CoCreateInstanceEx Lib "ole32.dll" _
(Clsid As Any, ByVal pUnkOuter As Long, _
ByVal Context As Long, Server As SERVER_STRUCTURE, _
ByVal nElems As Long, mqi As MULTI_QI) As Long
Private Declare Function GetComputerName Lib "kernel32" _
Alias "GetComputerNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
' The trick is to call CoCreateInstanceEx to do the dirty work - and get
' an iDispatch interface pointer in one step. This is very efficient,
' You get the IDISPATCH pointer by passing the 'well-known' REFIID of
' IDISPATCH. Unfortunately, not being able to do this as a constant,
' we can hard-code the REFIID into a little routine.
Public LastError As String
Public Function CreateRemoteObject(ObjectName As String, _
Optional ServerName As String) As Object
Dim clsid(256) As Byte
Dim progid() As Byte
Dim server() As Byte
Dim QI As MULTI_QI
Dim SS As SERVER_STRUCTURE
Dim refiid(16) As Byte
Dim lrc As Long
LastError = ""
' We only need to create the object remotely if the server name is not
' the same as our machine (or if it is empty, allowing this function to
' act as a general replacement for CreateObject)
If (Trim$(ServerName) = "") Or (UCase$(ServerName) = UCase$(GetCompName())) Then
On Error Resume Next
Err = 0
Set CreateRemoteObject = CreateObject(ObjectName)
If Err <> 0 Then
LastError = Err.Description 'record last error
End If
On Error GoTo 0
Exit Function
End If
'otherwise, it is genuinely remote.
GetIIDforIDispatch refiid() 'set an IID for IDispatch
QI.pIID = VarPtr(refiid(0)) 'point to the IID
progid = ObjectName & Chr$(0) 'specify the object to be launched
server = ServerName & Chr$(0) 'specify the server
OleInitialize 0 'initialise OLE
lrc = CLSIDFromProgID(progid(0), clsid(0)) 'get the CLSID for the object
If lrc <> 0 Then
LastError = "Unable to obtain CLSID from progid " & ObjectName & vbCrLf _
& "Possibly it is not registered on both this server and server " & ServerName
Exit Function
End If
' point to server name and
' invoke a remote instance of the desired object
SS.pServer = VarPtr(server(0))
lrc = CoCreateInstanceEx(clsid(0), 0, 16, SS, 1, QI)
If lrc <> 0 Then
LastError = "CoCreateInstanceEx failed with error code " & Hex$(lrc)
Exit Function
End If
Set CreateRemoteObject = QI.pInterface ' pass back object ref.
End Function
Public Sub GetIIDforIDispatch(p() As Byte)
' fills in the well-known IID for IDispatch into the byte array p.
p(1) = 4
p(2) = 2
p(8) = &HC0
p(15) = &H46
End Sub
Function GetCompName() As String
' return the computer name
Dim buf As String
Dim rc As Long
buf = String$(256, 0)
rc = GetComputerName(buf, Len(buf))
If InStr(buf, Chr$(0)) > 1 Then
GetCompName = UCase$(Left$(buf, InStr(buf, Chr$(0)) - 1))
End If
End Function
That's it. Just include this module in your project, then create your remote object using this syntax:
Dim O as MyServer.MyObject ' NB - you can use early binding !!!
Set O = CreateRemoteObject("MyServer.MyObject","MyServer")
CreateRemoteObject is pretty much a drop-in replacement for CreateObject.
|
|
|
|
|
sdaymond wrote:
>Thank you for your comment - that put me in the right direction. There is no doubt I have to create object dynamically in VB. For
that purpose VB has CreateObject but with CreateObject you cannot specify remote machine.
Check again. Search the docs for a CreateInstance() function.
Also, I would suggest you go to the MSDN Library
at http://msdn.microsoft.com/library/ and search on DCOM VB
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
I am recieving this error message while running HelloCli. (sorry as the last error message is in german). Can anyone tell me what did i do wrong?
Unable to access IHelloWorld because Der RPC-Server ist nicht verfügbar.
|
|
|
|
|