|
Hi All,
How do we handle dual LAN in DCOM.
Suppose I have two machines which are connected to two networks say network A & network B. Each machine has two IP addresses.
My Server is running on one machine & Client on another.
First of all when my Client makes a call to connect to the Server through which network will it get connected ? A or B ?
Moreover suppose the connection was established through network A. Now I want that when someone pulls out the network A LAN cable from Client's or Server's machine then the Client automatically gets connected to the Server through netwrok B.
Does DCOM has a solution for this ?
Please note that the Networks cards installed in the machines are normal cards. They do not form a team.
Best Regards,
Deepak
|
|
|
|
|
You get to decide to which machine the client will connect, by specifying the remote server name in COSERVERINFO structure when calling CoCreateInstanceEx ( or by setting the appropriate value for RemoveServerName into the registry for the server component). DCOM does not have such failsafe mechanisms - if you cannot use the primary server anymore try to switch to the other one.
|
|
|
|
|
Hi All,
How do we handle dual LAN in DCOM.
Suppose I have two machines which are connected to two networks say network A & network B. Each machine has two IP addresses.
My Server is running on one machine & Client on another.
First of all when my Client makes a call to connect to the Server through which network will it get connected ? A or B ?
Moreover suppose the connection was established through network A. Now I want that when someone pulls out the network A LAN cable from Client's or Server's machine then the Client automatically gets connected to the Server through netwrok B.
Does DCOM has a solution for this ?
Please note that the Networks cards installed in the machines are normal cards. They do not form a team.
Best Regards,
Deepak
|
|
|
|
|
Hi all,
I have the following code called from a worker thread in a DLL
HRESULT hRes = CoCreateInstance(CLSID_ToPickReg1,NULL,CLSCTX_INPROC_SERVER,__uuidof(IMyInterface),(void**)&m_pRegInterface);
and then I issue a call to a function like this
hRes = ((IMyInterface*)m_pRegInterface)->GetBinDir(&pChar,&errorCode);
where pChar is of type unsigned int * and the function signture is
CMyInterface::GetBinDir(unsigned char **ppuchBinDir, long *plErrorCode)
What I am getting is error 1783 or "The stub received bad data" in Win98 first edition with or without DCom98 installed, while in Win2000 everything works like a peach.
Any ideas?
Thanks in advance.
Alberto Gattegno
Software Engineer
http://www.itgil.com
|
|
|
|
|
This is more Word related than COM related, so I hope you don't mind me asking...
I am using automation of MS Word to build a Word document, and would like to add footers which contain the page number, in the format [some text] [page number] [some text].
It seems to be that you can set the text of the header and footer using HeaderFooter::GetRange() and then Range::SetText(), and you can add a page number to the footer using HeaderFooter::GetPageNumbers() and then PageNumbers::Add() , but you can't marry up the text and page number.
Any ideas on how I can tackle this. Alternatively, does anyone know of any good books that cover word automation to this sort of depth?
Thanks in advance!
|
|
|
|
|
Have actually found the solution now (not ten minutes after asking ), but thought I would post the solution as opposed to deleting the thread, in case anyone else had the same problem
Instead of adding to the PageNumbers collection, all you need to do is add a field of type wdFieldPage to the header / footer range. Simple really
|
|
|
|
|
I want to use my exe-server (attributed) in a MFC-application with several threads. In the main thread of the MFC-application I use smartpointers and CreateInstance to create an instance of the exe-server. By using CoInitializeEx(NULL, COINIT_MULTITHREADED) I get access to the server in every thread of my application. By using CoInitialize(NULL) just the main thread has access to the server, but that's clear. My Problem is, that if I use any ActiveX component in the application the threading model seems to be initialized automaticaly for single threading and calling CoInitialize is not possible anymore.
Is there a solution for my problem ?
|
|
|
|
|
The apartment is initialized for each thread once when you call CoInitInstance ( Ex). If you use COINIT_MULTITHREADED, you can pass around the interface ptr without any problems in any thread marked as MTA. Between threads with different apartments you must marshall the interface ( you can use CoMarshalInterThreadInterfaceInStream / CoGetInterfaceAndReleaseStream)
|
|
|
|
|
hello,
i try to create com objects which can be used by scripting clients and by c++ clients
very easily. this is no problem with the objects itself. but i have some trouble with
the events.
if i create the source interface as a standard interface based on idispatch the
wscript.exe crashes. if i look at the event proxy class generated by msvc, i see that
the methods on the interface are called directly, i think this will not work on script
clients. so i changed the interface to a dispinterface, now the generated proxy class
calls the method via invoke, scripting client works fine. but if i want to receive this
event in a simple c++ app the methods are not called directly, well, of course the
invoke method is called instead. so it is not so easy usable in c++. therefore i always
implement two source interfaces per object, on dispinterface as [default,source] for
script clients, and another iunknown based interface with the same methods as [source]
for c++ clients. this works fine, although it is more work to do. i do not know, if
there is a better way to support idispatch clients via invoke, and vtable clients directly
via the method calls? i thought maybe i can qi the interface connected to the cp, and
the idispatch connection will only return the idispatch interface, but it also returns
the event interface without error, but the method call fails.
second problem is that i do not get the automagic in wscript running. the event handler
is called the right way, but it is not executed. i always have to use the
WScript.ConnectObject obj, "obj_" method to connect to the events, then it is working
with vbscript. any idea why? do i need to support additional interfaces for the automagic
support? i added the IProvideClassInfo2Impl and IObjectWithSiteImpl to get the connect-
object method working.
and i have no idea how to use the events in a html-page with jscript. i do not get the
automagic working there, too, maybe the same problem. and attaching a function directly
to an event, like obj.event = myeventfunc, does not work, i always get the error, that
the object does not support the method or property. does it make any problems that the
event has parameters? the sample for onload, onclick do not have parameters. or is something
like the wscript.connectobject available for jscript and html?
well, that all for now, i hope someone could answer one or another? would be great.
many thanks in advance
enrico
|
|
|
|
|
I would like to offer the following decision.
[
oleautomation,
uuid(XXXXXXXX-XXXX-...),
helpstring("...")
]
interface ISomeEvents : IDispatch
{
[id(SomeDispid),helpstring("...")] HRESULT OnSomeEvent();
...
};
[
uuid(XXXXXXXX-XXXX-...), version(n.m), helpstring("...")
]
library SomeLib
{
...
[
uuid(XXXXXXXX-XXXX-...), helpstring("...")
]
coclass SomeCoClass
{
[default] interface ISome;
[default, source] interface ISomeEvents;
};
};
The sink of this interface can be implemented by ATL::IDispatchImpl instead of ATL::IDispEventImpl or ATL::IDispEventSimpleImpl.
With best wishes,
Vita
|
|
|
|
|
hello,
well, i tried this, but the result is almost the same. the msvc wizard creates a proxy class
with direct calls to the functions instead of the invoke, therefore the wscript crashes.
what i the idea of not using the dual? could you explain this? why use dual, why not?
enrico
|
|
|
|
|
I think that you should correct the Wizard to indirect call to the functions. Server must made a call only by Invoke. It's a script requirement.
But your C++ client can realize the sink more simply.
VB, VBS and all ole-automation clients will use the dispatch's Invoke.
But C++ clients can use ATL::IDispatchImpl class (with TLB inforamtion, but without BEGIN_SINK_MAP) instead of ATL::IDispEventImpl class (with manual BEGIN_SINK_MAP), which has also some bugs within it.
HTH
With best wishes,
Vita
|
|
|
|
|
oh, ok, i see, well this would be easier for c++ clients, you're right. thanks.
any idea how to get the automagic, the automatic assignment of events in a script
to the object_event methods working?
enrico
|
|
|
|
|
Can com post message to app? I own the COM and app.How to do this? Any function I can use?
|
|
|
|
|
Yes, it can - depends what you see under 'message'.
But in a general way - if it is interprocess COM he can use wide range of 'messages'.
First it is COM events - like ActiveX components also the COM library can fire events - this OnSomething functions.
It can also send the old plain window message (WM_USER ).
It can use the Win32 events - here the message is only 1 bit of info (evt set or not).
then its the whole range of IPC stuff (pipes, mailslots, sockets...).
Depends what you want to do and what you want to achieve.
|
|
|
|
|
Can you give me an example(source code)? many thanks.
|
|
|
|
|
Unfortunatelly, I do not have any source or example for sending message, but I think that this link will be useful - I check it quickly and I think it contains answer to all your questions with sending message
Message Management[^]
Hope this helps
|
|
|
|
|
Hello:
I have a basic problem. I create a COM server dll project. Then I create an ATL object (name: Test1). I select custom interface and I compile it. The server is registered OK, but when I launch the OleViewer I see that the Test1 object doesn't implement the ITest1 interface. Why?
Thanks in advance,
Jose.
|
|
|
|
|
1) Sometimes ( at least VC6 ) get's screwedup.... Find .tlb file and delete it...
2) Can you see your method/Interface when you view IDL????
Brian
|
|
|
|
|
I need my COM server to return an icon to my COM client. Can anyone suggest the best way of doing this?
I was thinking along the lines of my COM server loading a bitmap resource as (say) a CBitmap object. Then I could pass each byte (using the GetBitmapBits() function) in a SAFEARRAY to my client. My client could then build the bitmap locally (using the SetBitmapBits() function).
"The folly of man is that he dreams of what he can never achieve rather than dream of what he can."
"If you think education is expensive, try ignorance."
|
|
|
|
|
Another way is the looking at implementation of ATL :: CStockPropImpl :: put_Picture property.
Server old_Object -> quering IPersistXXXX interface -> making and fillng IStream object -> passing IStream to client -> loading client's new_Object from IStream.
I hope you are able to divide the CStockPropImpl code into server and client codes.
With best wishes,
Vita
|
|
|
|
|
Hi All,
I am working on a project(.dsp in Visual C++ 6.0) which
has multiple .idl files, many of these .idl files has
cross reference. Actually what I mean is, a function
inside file1's interface(interface_of_file1) takes a
parameter of file2's interface(interface_of_file2). Plus,
a function in interface_of_file2 takes parameter of
interface_of_file1. I hope you people got the idea that
both files need the other file to be compiled. In this
situation, if I import file2 in file1 and compile file1,
compiler tries to compile file2 first and gives error
that:
error MIDL2025 : syntax error : expecting a type
specification near "interface_of_file1" .
Now this is a kind of Dead Lock. I did Forward declaration
instead of importing the file(I do not exactly know the
method offorward declaration in MIDL). I did it in file1
like:
interface interface_of_file2;
Now this gives a different error and a warning:
==============================================
error MIDL2011 : unresolved type declaration :
interface_of_file2 [ Parameter 'parameter1' of
Procedure 'get_CashPeriod' (
Interface 'interface_of_file1' ) ]
warning MIDL2039 : interface does not conform to
[oleautomation] attribute : [ Parameter 'parameter1' of
Procedure 'get_CashPeriod' (
Interface 'interface_of_file1' ) ]
==============================================
Now please tell me, whether I'm doing forward declaration
wrongly? or can anyone suggest some other solution to this
problem?
I will be really thankful for any good answer.
Regards,
Ahsan
Ahsan
|
|
|
|
|
i think what you can do is to compile the first idl file using midl compiler and then include the generated files into the 2nd midl and then compile it..in this way hopefully u wont come across this problem again..
regards
safee
|
|
|
|
|
I am doing the same thing. What I do is that I right click the .idl file and compile only that file from there. Do you want me to specifically do it from command prompt? Btw, I have tried this as well But this gives the same problem.
What do you suggest now?
Ahsan
|
|
|
|
|
oh ok...i think then there is some problem in:
1. either the dependencies settings
2. the header files..
regards
|
|
|
|