accessing long pointer safearray structure in dll - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 32

Thread: accessing long pointer safearray structure in dll

  1. #16
    Join Date
    Mar 2014
    Posts
    17

    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.

  2. #17
    Join Date
    Mar 2014
    Posts
    17

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by VictorN View Post
    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;

  3. #18
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,266

    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. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  4. #19
    Join Date
    Mar 2014
    Posts
    17

    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..
    Attached Files Attached Files

  5. #20
    Join Date
    Mar 2014
    Posts
    17

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by sumlal View Post

    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.

  6. #21
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,291

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by sumlal View Post
    i can access the dll file through the foqadrive but its giving some error..
    Which errors (exactly!) was it giving you?
    Victor Nijegorodov

  7. #22
    Join Date
    Mar 2014
    Posts
    17

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by VictorN View Post
    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.

  8. #23
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,291

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by sumlal View Post
    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
    Victor Nijegorodov

  9. #24
    Join Date
    Mar 2014
    Posts
    17

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by VictorN View Post

    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.

  10. #25
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,291

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by sumlal View Post
    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?
    Victor Nijegorodov

  11. #26
    Join Date
    Mar 2014
    Posts
    17

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by VictorN View Post

    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.

  12. #27
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,291

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by sumlal View Post
    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 );

    What are you trying to add?
    Victor Nijegorodov

  13. #28
    Join Date
    Mar 2014
    Posts
    17

    Re: accessing long pointer safearray structure in dll

    Quote Originally Posted by VictorN View Post
    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,
    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.....
    Last edited by sumlal; April 1st, 2014 at 06:29 AM.

  14. #29
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,291

    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.
    Victor Nijegorodov

  15. #30
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,266

    Re: accessing long pointer safearray structure in dll

    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center