DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VB.NET problem with DPLOTLIB

 
Post new topic   Reply to topic    DPlot Forum Index -> Basic
View previous topic :: View next topic  
Author Message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Thu Oct 13, 2005 4:06 am    Post subject: VB.NET problem with DPLOTLIB Reply with quote

At this writing, the VB.NET example programs will not run correctly from within the VB.NET environment (the compiled examples work just fine). The problem the examples have is in finding DPLOTLIB.DLL. Windows searches for DLL's in this order:

  1. The directory from which the application loaded.
  2. The current directory.
  3. Windows 95 and Windows 98: The Windows system directory.
    Windows NT: The 32-bit Windows system directory.
  4. Windows NT: The 16-bit Windows system directory.
  5. The Windows directory. Use theGetWindowsDirectory function to get the path of this directory.
  6. The directories that are listed in the PATH environment variable.


The problem with #1 is "the application" in this case is the VB.NET IDE, not your project. In VB6 this is solved in the Form_Load event for the project with:

Code:
ChDrive App.Path
ChDir App.Path
ChDir ".."


"App" in this case is the project. For the examples, each project is located in a subfolder below the main \dplotlib folder, so this sequence sets the current directory (#2 in the list above) to the folder where DPLOTLIB.DLL resides. It still works with the compiled executable because #1 takes over (assuming DPLOTLIB.DLL is in the same folder where the executable lives).

The problem in VB.NET is there is no App object. If you try the above you'll just get an error message. The solution comes from Googling "VB.NET App.Path". There you'll find a replacement for App.Path:

Code:
Public Function App_Path() As String
    Return System.AppDomain.CurrentDomain.BaseDirectory()
End Function


You can add this function anywhere in the module where your Form_Load event is.

If you display App_Path in a MsgBox you'll find that it's the \bin folder below the project files. In the case of the example programs that's 3 levels below the \dplotlib folder. So in the Form_Load event for the examples, if you add:

Code:
ChDrive(App_Path())
ChDir(App_Path())
ChDir("..\..\..")      ' or ChDir("....")


before any calls to DPLOTLIB functions, then all will work as expected, whether run inside VB.NET or as a compiled executable. The above should of course be tailored to how your project files are arranged.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> Basic All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group