|
w_logan wrote:
Are both methods supported by all technologies like .Net, Java, etc...?
SafeArray(Type) is not supported by VB if my memory serves me right. It requires to stuff the array inside a variant.
|
|
|
|
|
Thanks for replying. I also happened to read about this in your interest exchange below after I had posted the thread.
This had cleared my doubts on why people are passing it as a Variant .
|
|
|
|
|
I have installed an COM object on an client machine. Then I am using an CAB file containing an OCX (with references to the COM Object) on the web to use the installed COM object.
When the Web page is loading I get this message
IE has blocked this site from using an ActiveX in an unsafe manner. As a result, this page may not display correctly
I have signed the CAB and OCX file, and the OCX is marked as safe and for initializing.
I am using Javascript to access the ocx from the web
Spaz
|
|
|
|
|
Is it marked as safe for scripting?
|
|
|
|
|
Yes
Provide the following registry keys for the control's CLSID under the Implemented Categories section:• The following key marks the control safe for scripting:
{7DD95801-9882-11CF-9FA9-00AA006C42C4}
• The following key marks the control safe for initialization from persistent data:
{7DD95802-9882-11CF-9FA9-00AA006C42C4}
In my .INF file from the CAB the above values exist...
Spas
|
|
|
|
|
|
Hi,
I need some help to find out how to access a com+ object remotly from client using vb.net. I exported the server component as an application proxy.In the client machine I tried to install the component as a proxy. But actual server component (dll and tlb )also goes to the client machine . Still I could not create an object using createObject (vb.net). My com+ component is vb.net .
Is there alternative way to access com+ object remotely other than exporting and insatalling as an application proxy ?
If this is the way,how can I prevent actual servercode (dll) goes to client?
Is a standard way to write com+ component to be access remotely?
Please help me
|
|
|
|
|
I am using System.Management.Managementobjectsearcher in C# to read processor Number. Internally it uses COM objects.
So it gives error that System.Runtime.Interopservices.COMException and error message is Com object is not registerd.
This error comes only in windows98. It works well with 2000,xp,2003 etc...
So tell me how to solve this error..
Nilesh Gambhava,
Life is NP-Complete so don't use Algorithm but use Heuristics
|
|
|
|
|
How can I place an activex property in a specified category other than misc.
|
|
|
|
|
Hi
I am trying to develop a class library that utilizes COM+ services using the ServiceConfig class in EnterpriseServices namespace and executes a piece of code in a transaction. The method does distributed database access. One of the database is sqlserver and I am able to acess the data fine. However, when trying to acess data on the DB2 running on a OS/390 platform, I get this exception "Attempt to establish connection failed with security reason "17" ("UNSUPPORTED FUNCTION"). SQLSTATE=08001". I have DB2 Connect version 8.2 installed and also created a datasource for accessing data.
I am not sure if I need to change any security settings in the DBM provided by DB2 Connect? However, if I don't utilize COM+ service in my class and do the DB2 database access, everything works fine. So, it is something related to COM+.
Also, is distributed database transactions using MSDTC supported for DB2 on OS/390?
Please help....
Thanks
|
|
|
|
|
I am having problems using CoMarshalInterThreadInterfaceInStream/CoGetInterfaceAndReleaseStream. I have a smart pointer IXMLDOMDocumentPtr which I want to share between a few different threads. I want to marshal it across my threads. I am using the aforementioned functions to do the same. What I see is that both the functions above return an S_OK and I finally get a IXMLDOMDocumentPtr in the other thread. I can use XPath to select nodes etc but when I try to get the owner document an exception is thrown "Invalid access to memory location".
In thread A I do the following:
typedef MSXML2::IXMLDOMDocumentPtr XML2DocumentPtr;
XML2DocumentPtr pDocXML;
pDocXML.CreateInstance(CLSID_DOMDocument);
pDocXML->load( "c://config.xml");
IStream* pIStream = NULL;
IID iid = __uuidof(IXMLDOMDocument);
HRESULT hr = CoMarshalInterThreadInterfaceInStream( iid, pDocXML.GetInterfacePtr(), &pIStream);
In thread B I do the following:
IID iid = __uuidof(IXMLDOMDocument);
XML2DocumentPtr pDocXML = NULL;
HRESULT hr = CoGetInterfaceAndReleaseStream(m_pIStream, iid, (LPVOID*)&pDocXML);
m_pIStream has already been saved after the CoMarshalInterThreadInterfaceInStream.
When I use the pDocXML to query the xml document for elements, nodes I can do that. But when I use the elements and nodes to ask for the owner document in order to create a new element or a node, I get the above mentioned exception "Invalid access to memory location". Any ideas as to what I might be doing wrong?
|
|
|
|
|
Have you tried marshalling through the GlobalInterfaceTable (GIT) instead?Since you are using the same interface in multiple threads this could be a comfy solution by simply register all the interfaces you need in the GIT and get them in your threads.
Don't forget to revoke the interfaces when your done...
I assume you have initialized COM in your threads with calls to ::CoInitializeEx....
--
Roger
|
|
|
|
|
Here is the problem.
I have several ActiveX objects that comunicate with each other. There is a central object, invisible, registered as active object with RegisterActiveObject() and several other objects that comunicate with it. Methods of the central object are called through IDispatch and events are trapped by "plugging" (with Advise()) an interface pointer in central object's connection point for events. Comunication works fine as long as all the objects are in the same process, when i put the central object in another process it doesn't work any more, I get a CO_INITIALIZE exception. I've tried to call CoInitialize in central object's thread but it still doesn't work.
If anyone could help me i would be very happy.
Thanks in advance.
Marius
|
|
|
|
|
I have an dual interface from which i am derving another interface..when i implement both the interface in the same class and when i compile i am getting "error MIDL2020 : error generating type library : AddImplType failed "
error message.
any help please..
Thanks
|
|
|
|
|
I have a simple test automation server (Delphi) that contains two coclasses, Foo & Bar. Foo has two properties that return an instance of Bar. At startup, Foo & the first instance of Bar are created in the main thread. A side thread creates the second property instance of Bar. All threads are intialized multithreaded & all class factories are free threaded and multi instance. The problem is when a late binding client, such as vbscript, attempts to access the second property, it claims it is not an object
Set Prop = Foo.Property2
Access to first property is fine. Compile so that both instances are created in main htread, no problem. Even though marshalling shouldn't be required in mutithreaded, I tried that as well w no change in behavior. This could be a Delphi problem, but I wanted to check to see if this could be a known COM limitation
Thanks
Bill
|
|
|
|
|
hope someone can help
im converting a c dll to an activex control (apparently the users cant figure out how to use a dll in vb) and have managed to get most of it functioning in a skeletal kind of way ... what im stuck with is the data
the code reads data from an external source within the activex and ive made it store it in an internal buffer ... i cant seem to get access to the data from vb ... i keep getting an error along the lines of "data type not supported by visual basic"
my question is ... what data type should i use to read and store raw byte data in the activex such that it can be read by the vb app?
thnx
"there is no spoon" biz stuff about me
|
|
|
|
|
l a u r e n wrote:
what data type should i use to read and store raw byte data in the activex such that it can be read by the vb app?
Basically any type defined by OLE Automation. That includes standard Microsoft types, but also those that you have defined in IDL. This is assuming that your client is Visual Basic, and not VBScript. VBScript is utterly lame and will only handle standard OLE types and enums, AFAIK.
How are you exposing your data? Arrays? Linked lists? Structures?
Good music: In my rosary[^]
|
|
|
|
|
hi jorgen
i looked thru the available types but didnt see a BYTE type thing ... did i miss it? in terms of exposing the data from the control to the VB client app im basically making the data a property of the control ... they can call a ReadData method to "refresh" the data from the source and there will be a WriteData method to send modified data back to the source
essentially it is 256 bytes of raw data
"there is no spoon" biz stuff about me
|
|
|
|
|
VB understands the BYTE type, but it sounds like you are passing a byte array, not a byte. Have you tried declaring the parameter as a SAFEARRAY??
|
|
|
|
|
|
Damn. rwestgraham beat me to it.
You will want to stuff the safearray into a VARIANT though, which you pass between C++ and VB. IDL supports a special safearray syntax, but VB doesn't understand it.
Good music: In my rosary[^]
|
|
|
|
|
ok hmmmmm now u lost me ... i thought variants were single variables so how can i stuff an array into one?
if im being dumb just tell me and i'll stop asking dumb questions
"there is no spoon" biz stuff about me
|
|
|
|
|
Not dumb, this stuff is complicated. I tested the below code in VC++6/VB6 and it worked.
ATL/C++ Server Code:
***************************************************************************
STDMETHODIMP CVBArray::GetVBArray(VARIANT *MyArray)
{
//Create a sample byte array and initialize with zeros
//256 is small, so don't bother creating on the heap
unsigned char bytearray[256] = {0};
//Declare a pointer to the byte array
unsigned char* pbytearray = bytearray;
//Set every other byte to 1
for(int i = 0; i <256; i+=2)
{
bytearray[i] = 1;
}
//Now comes the fun part!!!!
//Call VariantInit to initialize our return parameter
VariantInit(MyArray);
//Set the type of the return paramter to VT_UI1
//VB will recognize VT_UI1 as an unsigned char i.e. byte
MyArray->vt = VT_ARRAY| VT_UI1;
//Declare a pointer for a SAFEARRAY
SAFEARRAY* psa;
//Declare a SAFEARRAYBOUND and initialize it to the correct size
SAFEARRAYBOUND bounds = {sizeof(bytearray), 0};
//Create the SAFEARRAY using the type, dimension, and array length
psa = SafeArrayCreate(VT_UI1, 1, &bounds);
//Declare a null pointer for access to the SAFEARRAY's array
void* pSafeArrayData = NULL;
//Now set the pointer to the SAFEARRAY array (must be cast as void**)
SafeArrayAccessData(psa, (void**)(&pSafeArrayData));
//Let's review: We now have a local byte array populated with data.
//We also now have a SAFEARRAY object with a data buffer the size of our byte array.
//We have created a pointer for the SAFEARRAY's data buffer.
//We have "unlocked" the SAFEARRAY's data buffer and set our pointer to it
// by calling SafeArrayAccessData.
//Now all we need to do is copy our local data into the SAFEARRAY data buffer
// the clean up and return.
//Copy bytearray into SAFEARRAY buffer
memcpy(pSafeArrayData, pbytearray, sizeof(bytearray));
pbytearray = NULL;
//"Lock" the SAFEARRAY.
SafeArrayUnaccessData(psa);
//Set the SAFEARRAY we just created and populated to the return parameter.
MyArray->parray = psa;
//Now we are ready to return
return S_OK;
}
**************************************************************************
VB Code:
**************************************************************************
Private Sub GetArrayFromCOM()
Dim oServer As New vbArray
Dim testItems() As Byte
Dim i As Long
Dim count As Long
Dim strShow As String
testItems = oServer.GetVBArray
count = UBound(testItems)
For i = 0 To count
strShow = strShow & " " & CStr(testItems(i))
Next i
MsgBox strShow
End Sub
*****************************************************************************
|
|
|
|
|
|
And he beat me to it again! Jeez, I need to stop seeing women, because obviously they're taking up too much of my time..
To make rwestgraham's story short, it's the vt field of the variant which holds the secret. If you give it the value of VT_UI1|VT_ARRAY you can stuff a BYTE-safearray into it. You can even stuff structures (VT_RECORD ) in there too, should you ever have feel masochistic.
Good music: In my rosary[^]
|
|
|
|