|
I obtained the answer for this on another board. Basically, the problem is that I did not sign-on as administrator on my Visual Studio program.
|
|
|
|
|
Something puzzling is happening and I don't understand why. I tested using both my C# and VB.NET test apps and both result in the same behavior. When I run the application I have the following line (C#):
m_COMApp = new SignalServer.Application();
No matter what I do, I always get a new instance of the COM server, even if the server is already up and running. This does not happen in XP and I don't recall it ever happening under Vista (I plan to re-test that this weekend as I have Vista at home). This only happens when I run the COM client directly from within Visual Studio. I even changed my reference to point to another version of the server, and it still wanted to load the server found in the original directory.
I decided to run the application by double-clicking in Explorer and then I get the expected behavior. That is, if a server is already running, it will simply attach to the currently running server. Anyone know why I get the other behavior? Some thoughts are:
1) I am on Visual Studio 2005. Maybe this won't happen in 2010.
2) All the applications are 32-bit apps and the OS is 64-bit. Maybe because of the x86 directory names, things get a little messed up?
Anyone else experience this? Thanks for any information.
|
|
|
|
|
Are you running Visual Studio with UAC elevation?
Best Wishes,
-David Delaune
|
|
|
|
|
Aha! Thanks. That was the problem. I turned off UAC and everything works just as I would expect (like on XP)! I always leave UAC turned on because it's great for finding issues our customers will run into. I didn't even think about turning it off this time around.
|
|
|
|
|
Hi,
I am working on Excel Automation.
Implemented the logic to retrieve all the running Excel instances, now I am getting IDispatch pointer. Assigning this IDispatch Pointer to Excel object.
Following is the code:
IDispatch* p=NULL;
HRESULT hr = AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, __uuidof(IDispatch), (void**)&p);
if(hr == S_OK)
{
try
{
Excel::WindowsPtr pWindow = NULL;
HRESULT hr = p->QueryInterface(__uuidof(IDispatch),(void**)&pWindow);
Excel::_ApplicationPtr xl;
xl = pWindow->Application;
But getting com exception at above line. The com error: _Vfpointer: scalar deleting destructor(unsigned int) m_hresult:"Member not found".
I googled but there is no clarity in solution.
If any clue, please let me know.
Thanks in Advance.
Regards,
KTTransfer.
|
|
|
|
|
KTTransfer wrote: Excel::WindowsPtr pWindow = NULL;
HRESULT hr = p->QueryInterface(__uuidof(IDispatch),(void**)&pWindow);
What's the deal with this? You'd hope Excel::WindowsPtr wraps an IDispatch pointer (does it?).
Try this:
Excel::WindowsPtr pWindow = NULL;
HRESULT hr = p->QueryInterface(&pWindow);
Steve
|
|
|
|
|
I tried this,in this case I am getting "hresult hr" as "E_NOINTERFACE".
|
|
|
|
|
I'd take it at its word.
Steve
|
|
|
|
|
Hi,
I created windows application which reads the text file and loads into datagridview on clicking Open button. I would like to use this windows app in Internet Explorer browser. I created the below html and tried to access in IE. The design was shown perfectly and I clicked on Open button and selected text file in File Dialog box and I got the below exception. I found several posts regarding this issue in google. But those didn't solved the problem. Please guide me to resolve this issue. Thanks in advance..
Exception: "application attempted to perform an operation not allowed by the security policy. To grant this application the required permission, contact your system admistrator or use the Microsoft .NET Framework Configuration tool."
<html>
<body color=white>
<hr>
<font face=arial size=1>
<OBJECT id="myControl1" name="myControl1" classid="ActiveXDotNet.dll#ActiveXDotNet.myControl" width=800 height=450>
</OBJECT>
</font>
<hr>
</body>
</html>
ActiveXDotNet.dll is the application dll
ActiveXDotNet is the namespace
myControl is the class name
|
|
|
|
|
Hi,
I have an outproc server Executable which exposes an
Interface IServicer.
IServicer has a Method GetBytArray([in]BYTE* bytArray).
This method has to get a Byte array from client and
utilise the values of the array.
When iam calling this Interface method from client by
passing a byte array of size 10, at the server iam
only able to access the first element of the array.
i.e only first element of the array is marshalled from
client to Server. This is happening only in the case of
OUTPROC Servers. How can i access the entire BYTE array
without utilising VARIANT or SAFEARRAY concepts?
modified on Tuesday, May 18, 2010 1:00 AM
|
|
|
|
|
Where is the size_is[^] attribute (and others like length_is )? Given the client and server are in different address spaces clearly this information is required (COM isn't psychic).
Steve
|
|
|
|
|
Hi Steve,
Thanks for the Info.
I tried using Size_is option. Still nor working.
Can you give me a working Client Server Code?
Thanking you.
Arun
|
|
|
|
|
Did you register the proxy-stub? I'm betting no! Anyway I hacked this together:
The client:
#include "stdafx.h"
#import "../Server/Debug/Server.tlb" no_namespace
void DoIt()
{
IServicerPtr p;
HRESULT hr = p.CreateInstance(__uuidof(Servicer));
if (SUCCEEDED(hr))
{
BYTE data[] = {1, 2, 3, 4, 3, 2, 1};
p->SetData(sizeof(data), data);
}
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
CoInitialize(NULL);
DoIt();
CoUninitialize();
return 0;
}
The server's IDL (extract).
[
object,
uuid(3D71D2F1-E297-4B26-B2AC-32EA22EFC2B4),
helpstring("IServicer Interface"),
pointer_default(unique)
]
interface IServicer : IUnknown{
[helpstring("method SetData")] HRESULT SetData([in] ULONG size, [in, size_is(size)] BYTE * pData);
};
The server (extract):
STDMETHODIMP CServicer::SetData( ULONG size, BYTE * pData)
{
ostringstream oss;
for (ULONG i=0; i<size; ++i)
{
oss << static_cast<int>(pData[i]) << " ";
}
MessageBoxA(NULL, oss.str().c_str(), "Server", MB_OK);
return S_OK;
}
Steve
|
|
|
|
|
Hi Steve,
Thanks a lot for the code.
How to register the Proxy-Stub of my Outproc dll or exe?
|
|
|
|
|
What development environment are you using? What frameworks (if any) are you using to build the COM servers?
Steve
|
|
|
|
|
Im using Visual Studio 2003. In that i have taken an ATL Project.
Server type is: Service(exe) which exposes IServicer interface.
|
|
|
|
|
I built mine with 2008. What projects are in the workspace? Is there a project to build the proxy-stub (name ends in "PS")?
Steve
|
|
|
|
|
I have a Project named BytComp and BytCompPS in my workspace.
I built the BytCompPS and found ByCompPS.dll and registered it
using regsvr32 command.
Now, i have added a new interface method as suggested by you
but still im not able to access the entire array. 
|
|
|
|
|
Paste the code highlights as I did. Also, building the proxy-stub should have included a post-build step that registered it, so you shouldn't need to do it manually.
Steve
|
|
|
|
|
Hi Stephen,
What do you mean by Code highlights?
|
|
|
|
|
|
Ya i did the same way by copying you code.Still not able to
access the entire array.
Can you send me a working client server codes developed in VC98 or VS2003?
My Id: k_arunkumar_1217@yahoo.com
|
|
|
|
|
No, I mean paste in the important sections of your code here (like I did on the post I linked to).
Steve
|
|
|
|
|
IDL File Entry:
[id(5),helpstring("method SetData")] HRESULT SetData([in] ULONG size, [in,size_is(size)] BYTE *pData);
Method Override:
STDMETHODIMP CDataProvider::SetData(ULONG size, BYTE* bytArray)
{
// TODO: Add your implementation code here
BYTE byt[6];
int i=0;
for(;*bytArray!=0;i++)
{
byt[i]=*bytArray;
::MessageBox(NULL,(LPCTSTR)"he","Msg",MB_OK);
bytArray++;
}
byt[i]=0;
return S_OK;
}
Client:
IDataProvider* pServer=NULL;
HRESULT hr=::CoCreateInstance(CLSID_CDataProvider,NULL,CLSCTX_LOCAL_SERVER,IID_IDataProvider,(LPVOID*)&pServer);
short sSize = 5;
BYTE* pBytes;
//Allocate the shared Memory
pBytes = reinterpret_cast<byte *="">(CoTaskMemAlloc(sSize * sizeof(BYTE)));
if(pBytes == NULL)
return;
::memset(pBytes, 0, sSize);
pBytes[0]='K';
pBytes[1]='K';
pBytes[2]='R';
pBytes[3]='D';
pBytes[4]=NULL;
pServer->SetData(5,pBytes);
CoTaskMemFree(pBytes); //Free the shared Memory
|
|
|
|
|
There's many problems here. Firstly you haven't escaped the post properly so it's hard to read. For example:
K ARUN KUMAR wrote: reinterpret_cast(CoTaskMemAlloc(sSize * sizeof(BYTE)));
You didn't escape the < and > so some important code is missing.
You didn't bother to point out explicitly which code is in the client and which is in the server.
Surrounding code in <pre> and </pre> tags is generally considered polite, not to mention the fact that it makes the code more readable (uses a fixed width font).
You also didn't bother to ensure the code was properly indented.
In short, if you want help, put some effort in asking for it (at least as much as I do in replying!).
Now onto the code....
K ARUN KUMAR wrote: BYTE byt[6];
int i=0;
for(;*bytArray!=0;i++)
{
byt[i]=*bytArray;
::MessageBox(NULL,(LPCTSTR)"he","Msg",MB_OK);
bytArray++;
}
byt[i]=0;
This doesn't make use of size . Ever heard of buffer overruns?
What's with the (LPCTSTR)"he" ? Get rid of the cast. If the string is of the wrong type casting just turns what would have been a compiler error into a runtime error and solves nothing.
K ARUN KUMAR wrote:
//Allocate the shared Memory
pBytes = reinterpret_cast(CoTaskMemAlloc(sSize * sizeof(BYTE)));
if(pBytes == NULL)
return;
CoTaskMemAlloc does ***NOT*** allocate shared memory! You don't need to use it in this case (although there is no harm in using it).
Can you tell me more about what actually happens when you run it. Does the CDataProvider::SetData function get called? Does it display a MessageBox ? How many times?
Steve
|
|
|
|