Author Topic: dll is not loading at startup  (Read 12418 times)

JakeMontgomery

  • Community Member
  • Posts: 79
  • Hero Points: 8
dll is not loading at startup
« on: September 17, 2008, 02:32:37 PM »
I have a helper dll which I wrote, and which can be loaded using dload.  In v12 this dll got loaded at startup.  In 13.0.1 when I try to use any functions from it, I get the "File XXXX Not found" message.  If I manually dload the dll, then it works fine.  When I "List user loaded modules" from the Macro menu, the dll is listed at startup, but is not getting loaded. 

If anyone has any ideas how to fix this, I would appreciate it. I always need this dll, and tire of having to dload every time I run SE.

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: dll is not loading at startup
« Reply #1 on: September 17, 2008, 05:23:24 PM »
What I did in my EnhProj macro was to make the macro ensure the dll is dload'd before trying to use dll functions.  Alternating you could have a macro dload your dll in definit().
« Last Edit: September 18, 2008, 01:02:44 AM by chrisant »

JakeMontgomery

  • Community Member
  • Posts: 79
  • Hero Points: 8
Re: dll is not loading at startup
« Reply #2 on: September 18, 2008, 12:25:00 AM »
What I did in my EnhProj macro was to make the macro ensure the dll is dload'd before trying to use dll functions.  Alternating you could have a macro dload your dll in definit().

The definit thing seemed to work, thanks.
But it seems like a kludge to me ... and the dll should be autoloading ... at least that was the behavior in previous versions.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: dll is not loading at startup
« Reply #3 on: December 02, 2008, 03:31:15 PM »
Alternating you could have a macro dload your dll in definit().
Which definit()?  There seems to be one in almost every .e module...

JakeMontgomery

  • Community Member
  • Posts: 79
  • Hero Points: 8
Re: dll is not loading at startup
« Reply #4 on: December 02, 2008, 06:19:09 PM »
Alternating you could have a macro dload your dll in definit().
Which definit()?  There seems to be one in almost every .e module...

It should not matter. I have a .e file that I use for my personal macros, and I added a definit() to the top of that file. If you don't have any personal macro files, then you might try adding a definit() 'macro' to your vusrmacs.e

Good luck.

Dennis

  • Senior Community Member
  • Posts: 3961
  • Hero Points: 517
Re: dll is not loading at startup
« Reply #5 on: December 03, 2008, 07:27:29 PM »
Assuming the DLL is located in a path that the editor can consistently find (that is you can do "dload mydll.dll" without specifying the path) then the most likely issue is how you are exporting the functions in that DLL.

I am going to assume you are using vsDllExport(), as done in the sample DLL.  But, are you qualifying the functions with the DLL name, such that when the functions are called, SlickEdit can detect which DLL is needed and dynamically load it?

Example:
Code: [Select]
      vsDllExport("int mydll:myFunction(int,VSPSZ,VSPSZ)",0,0);

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: dll is not loading at startup
« Reply #6 on: December 03, 2008, 11:28:43 PM »
Aha, thanks, Dennis!  No, I was not specifying the dllname in the vsDllExport call.  The examples did not do so, and the help says "dllname is optional and indicates the name of the DLL which contains the function".  Might clear up confusion if the help added "so that the DLL can be loaded on demand when the function is called".

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: dll is not loading at startup
« Reply #7 on: January 15, 2009, 04:15:33 PM »
Assuming the DLL is located in a path that the editor can consistently find (that is you can do "dload mydll.dll" without specifying the path) then the most likely issue is how you are exporting the functions in that DLL.

I am going to assume you are using vsDllExport(), as done in the sample DLL.  But, are you qualifying the functions with the DLL name, such that when the functions are called, SlickEdit can detect which DLL is needed and dynamically load it?

Example:
Code: [Select]
      vsDllExport("int mydll:myFunction(int,VSPSZ,VSPSZ)",0,0);

How can that work?  The additional info SlickEdit needs to load the dll ("mydll:") is in the dll that SlickEdit hasn't loaded yet...
What am I missing? 

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: dll is not loading at startup
« Reply #8 on: January 15, 2009, 06:24:16 PM »
SlickEdit isn't prescient.  But once the dll is loaded once, the dll has to inform SlickEdit anyway about what functions it contains.  SlickEdit can remember the functions so it knows what dll to load later on (the information is stored in the state file).  SlickEdit has no way to know what dll is informing it about the functions, but if the dll informs SlickEdit of both the function signature and also which dll the function is in, then SlickEdit has enough information to automatically load the dll again later.  It's similar to how once you load a module, the functions in that module are available for macros, but not until you load the module.  The tricky part is just that the dll has to identify itself to SlickEdit since SlickEdit has no way to automagically figure out which dll is talking to it.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: dll is not loading at startup
« Reply #9 on: April 21, 2009, 11:26:02 PM »
I'm still having trouble getting this working.

I changed my vsDllExport calls to
Code: [Select]
vsDllExport("_command void SlickEditIntegration:VSNetIfc_Launch",          0, 0);

I first tried loading the dll via a junction I have set up:
[C:\Program Files]
Quote
>ls s*.

 Volume in drive C is unlabeled      Serial number is 5041:f3c5
 Directory of  C:\Program Files\s*.

 3/28/2009   8:51         <DIR>    ____D________  SlickEdit 2008
 4/21/2009  19:15         <DIR>    ____D________  SlickEdit 2009
 3/25/2009  19:49    <JUNCTION>    ____D___L____  SlickEdit2009 [C:\Program Files\SlickEdit 2009]

"dload c:\program files\SlickEdit2009\win\slickeditintegraton.dll" fails-- file not found.

"dload c:\program files\SlickEdit 2009\win\slickeditintegraton.dll" works as expected.

When I close and restart SlickEdit, though, and try to use a function exported from the dll, I get
 Error loading DLL 'C:\Program Files\SlickEdit2009\win\SlickEditIntegration.dll'

How do I get around this?

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: dll is not loading at startup
« Reply #10 on: April 22, 2009, 12:42:34 AM »
I changed my vsDllExport calls to
Code: [Select]
vsDllExport("_command void SlickEditIntegration:VSNetIfc_Launch",          0, 0);
Is the casing the same there as the actual file name?  Maybe it's case sensitive on Windows by accident?


"dload c:\program files\SlickEdit2009\win\slickeditintegraton.dll" fails-- file not found.
"dload c:\program files\SlickEdit 2009\win\slickeditintegraton.dll" works as expected.
Is the missing "i" in "...integraton.dll" a typo in the code, or in the post?


When I close and restart SlickEdit, though, and try to use a function exported from the dll, I get
 Error loading DLL 'C:\Program Files\SlickEdit2009\win\SlickEditIntegration.dll'
Have you tried "dunload" to unload any existing copy of the dll, before loading from a new path?


Maybe this weekend I can try using a junction to see how it works for me.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: dll is not loading at startup
« Reply #11 on: April 22, 2009, 01:02:53 AM »
Quote
Is the casing the same there as the actual file name?  Maybe it's case sensitive on Windows by accident?
Case is correct.

Quote
Is the missing "i" in "...integraton.dll" a typo in the code, or in the post?
Typo in post.  'dload' provides path/filename completion, so I know I'm loading the correct dll.  (dunload does not.)

Quote
Have you tried "dunload" to unload any existing copy of the dll, before loading from a new path?
Yes.  dunload on path-with-junction says "DLL not found".
Weird:  I try to the dload the dll, then recall that command and change it to dunload (to make sure the path/filename is identical) and I get a "File ... not loaded" error.

Strange that SlickEdit is hanging on to the dload command even after a newer one has been issued.
« Last Edit: April 22, 2009, 01:07:39 AM by Wanderer »