DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Thu Oct 13, 2005 4:06 am Post subject: VB.NET problem with DPLOTLIB |
|
|
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:
- The directory from which the application loaded.
- The current directory.
- Windows 95 and Windows 98: The Windows system directory.
Windows NT: The 32-bit Windows system directory.
- Windows NT: The 16-bit Windows system directory.
- The Windows directory. Use theGetWindowsDirectory function to get the path of this directory.
- 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 |
|