Re: accessing long pointer safearray structure in dll
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
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..
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.
Last edited by sumlal; March 26th, 2014 at 05:17 AM.
Re: accessing long pointer safearray structure in dll
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?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
Re: accessing long pointer safearray structure in dll
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.
Last edited by sumlal; April 1st, 2014 at 01:33 AM.
Re: accessing long pointer safearray structure in dll
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.
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
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.
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
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:
Re: accessing long pointer safearray structure in dll
Originally Posted by VictorN
Just because your dll code contains a serious bug here!
What could it mean:
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,
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.....
Last edited by sumlal; April 1st, 2014 at 06:29 AM.
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.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.