Re: accessing long pointer safearray structure in dll
Quote:
you are to provide a small compilable project or projects that together replicate your issue.
thanks for ur reply...
as i have mentioned in my post#1
Quote:
i am debugging a dll file for an application and i am getting some problem in accessing the safearray structure in the dll file.
the application wes developed in vc++ 2005 now upgrading it to vc++2008.
For the front end there using vb script 2005.
the thing is the application is developed in vc++6.0 and vb 6.0 platform. now i am instructed to upgrade them to vb.net version. i have upgraded the dlls to vc++2008 but when i am attaching them with the previous vb front-end code which is in vb 6.0 its showing this errors. the vb code is in vb 6.0 version but nw executing it in vb.net 2008 to test the dlls , is there COM conflict could arrise for that ? or any others error ?? please inform me..
Quote:
you show us how the function is declared in C++ dll but never do that for VB side.
and in vb side declaring dll function in module1.vb as
Code:
Declare Sub DatabaseInitialization Lib "engineDGCA.dll" (para() As ConfigTable, ByVal path As String)
engineDGCA.dll is the dll's name and DatabaseInitialization is the function name
rest of the code is in post#1
the reason y i ddnt mentioned the vb code because the vb code accessing the dll and executing the function . when i am giving any message to be printed before that line in the same dll , it print the message.
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
VictorN
Have you already fixed the "mistake" with ptrPARAMDATA and prtPARAMDATA variables I mentioned in the post#7?
thank u for ur reply sir....
yes i have already fix the "mistake" that u mentioned but its still giving the same problem..
the dll is working fine but when i am going to access the variable "cElements" its not responding.. even any member of the safearray structure is not responding like cDims, fFeatures, cbElements, cLocks, pvData;
Code:
(*ptrPARAMDATA)->rgsabound->cElements;
or
(*ptrPARAMDATA)->cDims;
or
(*ptrPARAMDATA)->cbElements;
Re: accessing long pointer safearray structure in dll
This may seem like 'a silly question', but how exactly have you 'upgraded' the application? Have any changes been made to the source code? Are the same compiler/linker options used? Have all programs that use the 'updated' code been re-linked/compiled? If you re-compile/re-link the code under the old development framework does it still work?
2 Attachment(s)
Re: accessing long pointer safearray structure in dll
thank u all for your valuable reply....
ok now i hv uploaded two files here..
1.foqadll (in vc++2008)
2.foqadrive (vb 2008)
i can access the dll file through the foqadrive but its giving some error..hope that ll help u to understand what the problem is..
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
sumlal
1.foqadll (in vc++2008)
i cant send the full executable dll because upload of zip file more than 500 kb not allowed.
so i am sending the code part of the dll.
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
sumlal
i can access the dll file through the foqadrive but its giving some error..
Which errors (exactly!) was it giving you?
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
VictorN
Which errors (exactly!) was it giving you?
i have mention a try block there as comments line, so its showing NulReferenceException was unhandled, i dont no also why this error is giving because i dont have that much idea about vb.
and if u remove the comment (') from the try block the program ll execute and its ll access the dll and from the vb normally its giving AccessViolationException was unhandled ....nw i have given some message line in the dll to print and if u see that after the "IN Foqadatabaseinitialization 3" its not printing the next message.
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
sumlal
i have mention a try block there as comments line, so its showing NulReferenceException was unhandled, i dont no also why this error is giving because i dont have that much idea about vb.
Did you try to google for it?
https://www.google.com/search?source...led+vb&spell=1
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
VictorN
thats ok that problem can be resolved.
but i stuck at the error that is comming from the dll...u can put that in a "try-catch" block the vb program will execute and u ll got the error from the dll.
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
sumlal
thats ok that problem can be resolved.
but i stuck at the error that is comming from the dll...u can put that in a "try-catch" block the vb program will execute and u ll got the error from the dll.
Well, did you search for the "AccessViolationException was unhandled" problem?
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
VictorN
yap...i have searched and what i got is if the application is accessing any unmanaged dll and if there is some problem in that dll , it cant show the error properly because dll is not having any compilation issue during execution and so only i have send the dll code also..
if u run the program with the dll u can c all msgs it ll display one-by-one but after the "in foqadatabaseinitialization 3" it is not showing the next msg.
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
sumlal
yif u run the program with the dll u can c all msgs it ll display one-by-one but after the "in foqadatabaseinitialization 3" it is not showing the next msg.
Just because your dll code contains a serious bug here!
What could it mean:
Quote:
Originally Posted by sumlal
Code:
MessageBoxA(NULL, "cElement = "+(*ptrParamData)->rgsabound->cElements, " NULL ", MB_OK );
:confused:
What are you trying to add?
Re: accessing long pointer safearray structure in dll
Quote:
Originally Posted by
VictorN
Just because your dll code contains a serious bug here!
What could it mean::confused:
What are you trying to add?
ya that line is having the problem..
i only added that line to access the (*ptrParamData)->rgsabound->cElements of the safeArray structure. i dont have that much idea about the safeArray structure.
the previous developer has included this line to the program,
Code:
PARATable = (PARAMETERS *) malloc (sizeof(PARAMETERS) * (*ptrParamData)->rgsabound->cElements);
and even i cant understand why that line for. If u see the rest of the code, The only reason that i can found to add that line is to allocate the memory dynamically for the PARATable. but whatever i got to know from the google the cElements must have to initialize before use. Although here they haven't initialized it (i have search all reference for the cElements throughout the project) but used it to allocate the memory.
they have simply passed the value to the SafeArray structure
now what my doubt is : does the cElements can be automatically initialize if some values are passing to the SafeArray variable ? and the second is : in this example i have passed some value to the SafeArray structure and how to access the value from the SafeArray variable that i have passed ?
i already have googled about SafeArray many time but can't find needed information, can u help me out to get all the detailed information about SafeArray structure and how it works..
or can u figure it out where the problem is in the program.....
Re: accessing long pointer safearray structure in dll
Dear sumlal,
it is very hard to communicate with you because you either don't accept the things others here suggest you or just show every time some new part of the code or some different error messages.
As for using safearrays - I already wrote you in the post#5 that you should use SafeArrayAllocDescriptor and SafeArrayAllocData functions to allocate safearray memory. Just search MSDN for these functions to find the code sample.
Re: accessing long pointer safearray structure in dll