|
Hi,
I have Simple ActiveX dll for opening connection to the database
and execute a stored procedure which returns a RecordSet.
I added it to the Component Services as a COM component
I spawned 10 threads to create object for COM and called the
method defined in the COM dll in Serialized Transaction support
and in ReadCommitted support.
I didnt notice any diffence in the execution time of the stored
procedure in both the cases.
What may be the reason?
With Thanks
Sakthi
|
|
|
|
|
Hi All:
I was trying to Used Distributed Transaction with Thread to allow many
Inserting operations into Different Databases in Different Server at the same
time
My Question is can we applying the Distributed Transaction and Threading
Together.
I try to apply it But the folowing Problem appeares through Open the first
Database Connection
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in mscorlib.dll
Additional information: The component is configured to use synchronization
and this method call would cause a deadlock to occur.
' Some oF My The Code
Private strDBQA As String = "Data Source=QASRV; Initial Catalog=employee;
Password=sasa; User ID=sa"
Private strDBFA As String = "Data Source=FADI; Initial Catalog=Employee;
Password=sasa; User ID=sa" 'Enlist =false"
Private _Itransaction As System.EnterpriseServices.ITransaction
Private _boolQ As Boolean = False
Private _boolF As Boolean = False
Public ReadOnly Property PITransaction()
Get
Return _Itransaction
End Get
End Property
'The Main Function
Function TestThread(ByRef strError As String)
Try
_Itransaction = System.EnterpriseServices.ContextUtil.Transaction
Dim objThread As System.Threading.Thread
objThread = New System.Threading.Thread(AddressOf QServer)
objThread.Start()
objThread = New System.Threading.Thread(AddressOf Fserver)
objThread.Start()
If _boolF = True AndAlso _boolQ = True Then
ContextUtil.SetComplete()
strError = "Completed"
End If
Catch ex As Exception
ContextUtil.SetAbort()
strError = ex.Message
Catch ex As Exception
End Try
Private Sub QServer()
Try
Dim oConnectionQ As New SqlClient.SqlConnection
Dim cmdSql As New SqlClient.SqlCommand
oConnectionQ .ConnectionString = strDBQA
oConnectionQ .Open()
oConnectionQ .EnlistDistributedTransaction(PITransaction)
cmdSql.Connection = oConnectionQ
cmdSql.CommandText = "update Test set ID = ID + 10"
cmdSql.ExecuteNonQuery()
_boolQ = True
If _boolF = True AndAlso _boolQ = True Then
ContextUtil.SetComplete()
End If
Catch ex As Exception
ContextUtil.SetAbort()
End Try
End Sub
Private Sub Fserver()
Try
Dim oConnectionF As New SqlClient.SqlConnection
Dim cmdSql2 As New SqlClient.SqlCommand
oConnectionF .ConnectionString = strDBFA
'================
' in the strF oPen The Error Appear
oConnectionF .Open()
oConnectionF .EnlistDistributedTransaction(PITransaction)
cmdSql2.Connection = oConnectionF
cmdSql2.CommandText = "update Test set ID = ID + 10"
cmdSql2.ExecuteNonQuery()
_boolF = True
If _boolF = True AndAlso _boolQ = True Then
ContextUtil.SetComplete()
End If
Catch ex As Exception
ContextUtil.SetAbort()
End Try
End Sub
F.mathkour
|
|
|
|
|
|
Can i save array of int values into attribute using put_value method????
Because i have some problem with this. It save only first element of array.
Maybe i have some error in my code,
int *arr = new int[ 5 ];
for( int i = 0 ; i < 5 ; i++ )
arr[ i ] = i;
VARIANT var;
var.vt = VT_BYREF|VT_INT;
var.pintVal = &arr[0];
hr = spXMLDOMAttribute->put_value( var );
|
|
|
|
|
vippavlo wrote: Can i save array of int values into attribute using put_value method????
Because i have some problem with this. It save only first element of array.
Maybe i have some error in my code,
int *arr = new int[ 5 ];
for( int i = 0 ; i < 5 ; i++ )
arr[ i ] = i;
VARIANT var;
var.vt = VT_BYREF|VT_INT;
var.pintVal = &arr[0];
hr = spXMLDOMAttribute->put_value( var );
I don't think you can just save an array to an attribute, but I do know that VT_BYREF doesn't make it an array. If this were to work at all, you would have to create a SAFEARRAY and make a variant of type VT_ARRAY | VT_INT
Nathan
|
|
|
|
|
Thanks for answer))) i found some info about this and now i know that i should be use SAFEARRAY.))
Sory for some grammar mistakes. I'm from Ukraine and don't know Enlish perfect
-- modified at 18:09 Monday 24th September, 2007
ISQ 469907496
|
|
|
|
|
Do you know exactly that SAFEARRAY will be stored correct in attribute???
Because i have a problem when i put value into attribute: "Type mismatch". What it mean??? May be i create SAFEARRAY uncorrect???? If you have some example for putting CComSafeArray into CComVariant, please give me, i'll be much obliged to you.
ISQ 469907496
|
|
|
|
|
vippavlo wrote: Do you know exactly that SAFEARRAY will be stored correct in attribute???
Because i have a problem when i put value into attribute: "Type mismatch". What it mean??? May be i create SAFEARRAY uncorrect???? If you have some example for putting CComSafeArray into CComVariant, please give me, i'll be much obliged to you.
I believe I mentioned in my last reply that you probably can't store an array in an XML attribute. Type mismatch is the error I'd expect if it wasn't allowed. You can probably define your own method to convert the array to and from a string, since string is the real type of the attribute anyway. While I'd just drop SAFEARRAYs for what you are doing, I've found an example of creating a SAFEARRAY in the MSDN documentation:
SAFEARRAYBOUND sab;
sab.cElements = 2;
sab.lLbound = 0;
hresult hr;
SAFEARRAY * pSa;
pSa = SafeArrayCreateEx(VT_RECORD, 1, &sab, pRecInfo);
if (pSa == NULL)
return E_OUTOFMEMORY;
PVOID pvData;
hr = SafeArrayAccessData(pSa, &pvData);
if (FAILED(hr)) {
SafeArrayDestroy(pSa);
return hr;
}
TEST * pTest;
pTest = (TEST *)pvData;
pTest[0] = a;
pTest[1] = b;
hr = SafeArrayUnaccessData(pSa);
if (FAILED(hr)) {
SafeArrayDestroy(pSa);
return hr;
}
VariantInit(&variant);
V_VT(&variant) = VT_ARRAY|VT_RECORD;
V_ARRAY(&variant) = pSa;
This code uses basic COM functions instead of MFC, but CComVariant is designed to work with any function that takes a VARIANT. If you are using ATL, there is a CComSafeArray class that can simplify it some more.
Nathan
|
|
|
|
|
Thanks..
I thought that i create array uncorrect, but now i understand that value can't to be an array.
ISQ 469907496
|
|
|
|
|
//Its tt.java simple Helloworld program .which i am willing to call from c++
// i created .class and .h file of it !
public class tt {
public static void main(String[] args) {
System.out.println("Hello World ");
}
}
//*****************************************************************************************
//i wrote it in vc++ 6.0
//for this i added path of tt.h(created using javah) in preprocessor path(underprojects=>setting=>c/c++ tab)
//then added path of jvm.lib (under projects=>setting=>link tab)
#include "jni.h"
#define PATH_SEPARATOR ';' /* define it to be ':' on Solaris */
#define USER_CLASSPATH "C:\j2sdk1.4.2_05\bin" /* where tt.class is */
int main()
{
JNIEnv *env;
JavaVM *jvm;
jint res;
jclass cls;
jmethodID mid;
jstring jstr;
jclass stringClass;
jobjectArray args;;
JavaVMInitArgs vm_args;;
JavaVMOption options[1];
options[0].optionString ="-Djava.class.path="USER_CLASSPATH;
vm_args.version = 0x00010002;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = JNI_TRUE;
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if (res < 0) {
fprintf(stderr, "Can't create Java VM\n");
// exit(1);
}
cls = (env)->FindClass("tt");
if (cls == 0) {
// goto destroy;
}
mid = (env)->GetStaticMethodID(cls, "main","([Ljava/lang/String;)V");
if (mid == 0) {
// goto destroy;
}
jstr = (env)->NewStringUTF(" from C!");
if (jstr == 0) {
// goto destroy;
}
stringClass = (env)->FindClass("java/lang/String");
args = (env)->NewObjectArray(1, stringClass, jstr);
if (args == 0) {
// goto destroy;
}
(env)->CallStaticVoidMethod(cls, mid, args);
//destroy:
if ((env)->ExceptionOccurred()) {
(env)->ExceptionDescribe();
}
(jvm)->DestroyJavaVM();
return 0;
}
/// After doing that much ! i got this LINKING TIME ERRORs
--------------------Configuration: ltry - Win32 Debug--------------------
Compiling...
Skipping... (no relevant changes detected)
tr.cpp
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/ltry.exe : fatal error LNK1120: 1 unresolved externals
// please help me sir....what chages i should do so that it gets run n calls java method ?
|
|
|
|
|
I try to call a function inside a aggregated interface IMyInterface
and it pops up this error ->
Run-Time Check Failure #0 - The value of ESP was not properly saved
across a function call. This is usually a result of calling a
function declared with one calling convention with a function pointer
declared with a different calling convention.
This is the code that i used,
IMyInterface* pMy = NULL;
HRESULT hr = m_pInterface->QueryInterface(__uuidof(IMyInterface),
(void**)&pMy);
pMy->GetValue();
When i call the GetValue function the Run-Time error comes up.
Any Idea?
|
|
|
|
|
donguy76 wrote: I try to call a function inside a aggregated interface IMyInterface
and it pops up this error ->
Run-Time Check Failure #0 - The value of ESP was not properly saved
across a function call. This is usually a result of calling a
function declared with one calling convention with a function pointer
declared with a different calling convention.
I only have the obvious ideas. What calling convention is GetValue declared as?
Nathan
|
|
|
|
|
i am trying to use dll created in VC++ in ASP.Net but it gives an error of Security i have try caspol but still it gives an error.
Waiting for solution
Best Regards,
Chetan Patel
|
|
|
|
|
Does anyone know how the Groove 'Folder Sync' button is added to the standard Windows Explorer toolbar?
|
|
|
|
|
Hi,
Why we need COM. I know i have asked this question already, but i need direct answer in line or two
Thanks
|
|
|
|
|
Nandu_77b wrote: Why we need COM. I know i have asked this question already, but i need direct answer in line or two
We need it as a binary standard for program modules to communicate. This can make upgrading modules easier if everyone follows the rules.
Nathan
|
|
|
|
|
|
If you are interested in a clear but complex explanation of what the original motivatations were for creating COM, try to find a copy of "Essential COM", by Don Box. That book will also describe the basic structural layout of the binary components.
|
|
|
|
|
Hello Friends,
I've a problem with some com+ components developed in vc++, and running on w2003 sp2, the problems is simple, when an error happend in the component (yes it can happend on best families with big loads ), the component manager must close this component and recycle it, but some times, the system thows a message to the OS console, this message it's the well known:
dllhost - Application Error
The instruction at "0x1002650d" referenced memory at "0x0000000". The memory could not be "written".
Asking the user to continue or debug.... opsss user interaction on a service is not a good idea
Sometimes this is easy to solve, will you think, just correct your code, but other times, this only ocurr with high load, or networks errors that make your program fail, and the component manager must do his job
When a small number of this messages (20/30) are in the console, the component manager fail and doesn't do his job, at this moment the component manager it's down and you will manualy kill dllhosts or interact with the console !!
¿Does any body knows how to solve this kind of problem, preventing component manager to ask for user interaction on an error?
Regards,
Vider
-- modified at 8:00 Tuesday 18th September, 2007
|
|
|
|
|
Hi,
Actually i have 2 questions!
Somehow related.
I have a dll,lets call it database.dll,it reads a very big file when it is loaded,and with some procedures expoerted,i can access that data.
I was wondering if 2 or 3 applications that use that dll,does loading from file happen 2-3 times or only once?
i mean is those database datas global between dlls or not?
And,
I have a com server,in a dll file,that exposes 2 interfaces,for 2 different jobs.And also there are some global classes and functions that both of them use.
But both of them rely on procedures from my database.dll,again,should i forexample call 2 times loadlibrary,and initialize my database,or simply once is enough?(i load dll by loadlibrary,abd getprocaddress)
and if yes,is there any way i can prevent it?becouse loading that file takes around 20-30seconds which i dont want it to happen twice...
regards,
roozbeh
|
|
|
|
|
rozbeh wrote: I have a dll,lets call it database.dll,it reads a very big file when it is loaded,and with some procedures expoerted,i can access that data.
I was wondering if 2 or 3 applications that use that dll,does loading from file happen 2-3 times or only once?
i mean is those database datas global between dlls or not?
In this case, the file would be loaded 2 or 3 times. There are techniques like shared memory blocks that could allow you to load the file just once, but they will make things more complicated.
rozbeh wrote: I have a com server,in a dll file,that exposes 2 interfaces,for 2 different jobs.And also there are some global classes and functions that both of them use.
But both of them rely on procedures from my database.dll,again,should i forexample call 2 times loadlibrary,and initialize my database,or simply once is enough?(i load dll by loadlibrary,abd getprocaddress)
and if yes,is there any way i can prevent it?becouse loading that file takes around 20-30seconds which i dont want it to happen twice...
If a single application loads a dll twice, LoadLibrary will return the same instance of the dll both times, so loading only once should be relatively easy.
Nathan
|
|
|
|
|
Hy vokes!
How is it going.
My problem I should access a Interface over a Network with Malab. But when I tried it failed. A other Interface is no problem. I saw also Codes where this interface where used.
So here is what I am searching for:
Is there a possibility to get the Information, what COM Processes are activated over the Network?
And of course which command is it?
I hope someone can help cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
Hi,
Right now I am developing a COM wrapper for some native C++ classes. Those native C++ class vastly use STL containers for their inputs and outputs. I provided COM interfaces for each of those containers in COM wrapper side. But when I want to pass in the collection of values from COM wrapper side to native C++ side, I am extracting the internal object (ex. a vector/list/map/set) in the COM wrapper side which holds the values.
For extracting the internal object (a STL container), I type casted the whole STL container to void ** and returning the value. Again, In my client side, i am retype casting to get the required STL container.
But for me, this typecasting is not working all the time. what is the best way to extract the internal object?
An example scenario:
in Native C++, the following code is working fine.
vector<int>* pV = new vector<int>
pV->push_back(10);
pV->push_back(20);
pV->push_back(30);
void *pVoid = (void*) pV;
vector<int>* oV = (vector<int>*)pVoid;
the above code is working fine, if it is native C++ side.
when it comes to COM,
ISomeCollection *pColl;
void *pV = NULL;
pColl->InternalObject(&pV);//signature is InternalObject (void**)
vector<int>* pVec = (vector<int>*) pV;
the above code is not working all the times.
Any suggestions for this code is highly appreciated.
thanks
Ng
|
|
|
|
|
true627 wrote: when it comes to COM,
ISomeCollection *pColl;
void *pV = NULL;
pColl->InternalObject(&pV);
vector* pVec = (vector*) pV;
the above code is not working all the times.
Any suggestions for this code is highly appreciated.
I don't think you're supposed pass things like pointers to STL objects in COM, because you're supposed to not make clients depend on implementation details of your class. In particular, a process called "marshalling" depends on things being spelled out in .idl files in ways that STL doesn't guarentee. I think it would be more appropriate to provide "Item" for accessing specific items of the vector, and "Count" for finding the vector's size. If you need more access than that, you can write a "Contents" method which returns a pointer to the vector's contents and the number of elements, which can be described in IDL enough to be marshalled properly.
Nathan
|
|
|
|
|
Hi Nathan,
Thanks for your suggestion.when I want to provide a pointer to my vector contents inside my COM object, what would be the best way to expose the pointer to the client other than void*? For my case, assume that vector item will be of any data item? I also have restrictions in using VARIANT in my interfaces.
thanks once again,
Ng
|
|
|
|
|