|
Hello,
I've written a C# out-of-proc COM server (I delete the Inproc registry entry and add a LocalServer32 entry to get my EXE working as a COM server - then I register a class factory in the server's main method). The server works well when I access it from VB6 (I can instantiate the EXE with CreateObject and always get the same server object from my class factory, as I desire it). Now I need to write a C# client. I instantiate the object via Activator.CreateInstance, passing the progid. I get the server instance. But as soon as I am trying to register an event handler on one of the server's events, I get an AccessViolationException (subscribing events works well in the vb client). Simple method calls without parameters do work. When I run the server in-proc, I don't get the exception.
Is there any possibility to get this working? Or is it fundamentally wrong to simply register the component as LocalServer32?
Thank you,
Thorben
|
|
|
|
|
I am writing a function in C++ that has a SAFEARRRAY as a parameter. I have followed the example from: http://support.microsoft.com/kb/167668[^]. My code is basically the exact as in this example except for the name of the array.
The problem I am running into is that I get the error "E_UNEXPECTED" when calling SafeArrayAccessData. The documentation says that is error occurs when the array could not be locked.
Any Suggestions?
Thank you in advance.
|
|
|
|
|
The line:
if (V_VT(vArray) != (VT_ARRAY | VT_BSTR))
is return TRUE, which make me think that this not a valid array, but in my vb code that calls this function I have a string array that is getting properly assigned.
In the link above, they say, "The key to getting this syntax to work in Visual Basic 6.0 is to first Dim the array variable as a variant, and then ReDim it so that it becomes a variant containing an array of strings. "
Part of the problem is that I am not using VB6.0, I am using .Net 2005. They do not allow the Redim to change the type any longer.
Thanks again for any help you may have.
|
|
|
|
|
Here is my code:
Identifier is passed into the function as VARIANT FAR*
long lLBound, lUBound;
long count = 0;
BSTR HUGEP *strIDs;
SAFEARRAY FAR* ID_Array = NULL;
ID_Array = V_ARRAY(Identifier);
if (V_VT(Identifier) == (VT_ARRAY | VT_BSTR | VT_BYREF))
{
// Get array bounds.
lResult = SafeArrayGetUBound(ID_Array, 1, &lUBound);
if (FAILED(lResult))
{
return count;
}
lResult = SafeArrayGetLBound(ID_Array, 1, &lLBound);
if (FAILED(lResult))
{
return count;
}
// Get a pointer to the elements of the array.
lResult = SafeArrayAccessData(ID_Array, (void HUGEP**)&strIDs);
if (FAILED(lResult))
{
return count;
}
}
SafeArrayAccessData is always returning E_UNEXPECTED. The other functions work fine.
|
|
|
|
|
Hello Cajunman0821,
I tried out your code together with a sample client written in VB 6.0 using the client code given in the MSDN URL you indicated.
Everything worked correctly and I did not get any E_UNEXPECTED error result.
You mentioned that you are not using a VB 6.0 client and are instead using ".NET 2005" (is this a C# or VB.Net app or an app written in another .Net language ?).
My impression is that the client code is either locking the string array (that you passed to your C++ code) or it has not wrapped it properly inside a .Net Object. A .Net Object is used as the equivalent to a COM Variant.
- Bio.
|
|
|
|
|
If V_VT(Identifier) == (VT_ARRAY | VT_BSTR | VT_BYREF), then Identifier contains a pointer to array of BSTRs, and you should use a V_ARRAYREF macro to get access to array of BSTRs.
if (V_VT(Identifier) == (VT_VARIANT | VT_BYREF))
Identifier = V_VARIANTREF(Identifier);
if (V_ISARRAY(Identifier))
{
ID_Array = V_ISBYREF(Identifier) ? *(V_ARRAYREF(Identifier)) : V_ARRAY(Identifier);
...
}
With best wishes,
Vita
|
|
|
|
|
I owe you a beer, Vita.
That worked perfectly. Thanks.
|
|
|
|
|
Hi,
I'm new to COM ports.
Kindly: How can I turn on and Off the bluetooth on my pocketpc/WM5 device using a COM port?
I would like to do this from the front end, from my device.
prefered language = vb.net.
Dikran
modified on Thursday, May 14, 2009 9:34 AM
|
|
|
|
|
is it possible to do this?
|
|
|
|
|
Hi,
I've had a problem when I'm trying to use an activeX function that has a pointer parameter in JavaScript. Other activeX funtions all can be successfully called in javascript. The definition of the activeX function (written in VC++) is shown as follows:
NewCommand(ULONG DevID,ULONG* pCmdStruct) The problem I encountered is how to call this function in javascript.
var a;
a = 1;
var pdat = new Array(1);
pdat[0] = 1;
document.ActiveXObject.NewCommand(a,pdat);
When I use the above sentences, it occurs an error "Run-time error:Type mismatch".
If someone knows something about this topic that can help me, I will appreciate it.
Thanks!
modified on Wednesday, May 13, 2009 2:08 AM
|
|
|
|
|
AFAK ULONG * is not a OLE automation compliant type, hence your ActiveX function cannot be called by the Javascript client (i.e. I suppose you've to define a new interface, automation compliant).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks a lot!
I've changed the activex function with a pointer parameter included into a normal form (without pointer) and it works all right, and it also realizes the function that I want.
|
|
|
|
|
pls can someone explain what the moniker mean in com programming hope the explain in visualbasic thx in advance
monem
|
|
|
|
|
Moniker is used to identify a COM object.
This is very useful in distributed system where COM objects are distributed over a network.
Monikers can be used to identify, activate and access any COM object in a system.
Check out IMoniker[^] for more information.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
thx very much superman but i was hope see example using moniker
monem
|
|
|
|
|
|
Hi everyone.
I have created a COM Dll using .Net2.0 (VS2005) and interop.
When I use "CreateObject" using VB.NET (2.0) it works fine and the COM class is created.
When I use CreateObject from VB6 , it also works fine!!
But, When I use VB.NET (1.1) for "CreateObject" (of the same COM Dll) , I get :
"Cannot Create ActiveX component"
My client needs my wrapper (COM) and he works with .Net1.1 ....
Do anyone know this problem ? Know a solution ? even a workaround will do
Thanks!
|
|
|
|
|
I am developing ComAddin for winword in which i'm not getting DocumentOpen notification for a particular document.
But at the time of closing,I'm getting notification at DocumentBeforeClose.
That particular file does not contain any macro.
At the time of opening it is showing the macro-Warning(macros have been disabled)
If i enable the content, i'm getting the "File Not found" error message from Visual Basic.
Because of this macro I'm not getting open call or there would be some other reason.
Thanks in advance.
|
|
|
|
|
If you are able to sink documentopen same as documentbeforeclose then there will not be any problem that u have coded. Since your documentbeforeclose is working fine. This could be bacoz of macro. try to remove macro and then run ur addin.
SNI
|
|
|
|
|
Hi,
I am developing an application where we require to get the event of menu click on each menu (e.g. File-->New, Save, Close,Exit OR Edit--> Copy,Paste..). I am trying to get common event for all the menus so that I will come to know which menu is clicked by identifying Caption of it and then I will work accordingly.
Any suggestions on this will be helpful
Thanks
SNI
|
|
|
|
|
Have you found a solution to that problem? I need to sink File->Save event in word but I can't find any documentation about it.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi.
I want to print a regedit key to web page with activeX. Like (HKEY_CURRENT_USER\Control Panel\Colors) When a guest visits my page and accept activex controls. I want to show my visitor "The key you requested from regedit is : ... "
Thanx for helpers already.
|
|
|
|
|
If so, where could I find a list of the class object GUIDS?
|
|
|
|
|
Klempie wrote: If so, where could I find a list of the class object GUIDS?
Is it April 1st again already? Is Twitter down? Did you pick a bad day to stop smoking crack?
WTF dude?
|
|
|
|
|
No it's not April 1st, I don't give a toss about Twitter and I've never taken drugs in my life. Now that that is out of the way, could you please give me a straight answer?
Thanks in advance.
|
|
|
|