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 

DPLOTLIB.DLL with VB 2008

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



Joined: 16 Jan 2007
Posts: 12

PostPosted: Thu Jul 08, 2010 5:30 pm    Post subject: DPLOTLIB.DLL with VB 2008 Reply with quote

David:

I successfully developed an application with VB 2005 that called DPLOTLIB.DLL using the example included with the software:

Code:
Public Sub DPlot_FindDPLOTLIB()
    ' Find DPLOTLIB.DLL.
    Dim key As Microsoft.Win32.RegistryKey
    Dim path As String
    Dim hLib As IntPtr

    hLib = LoadLibrary("dplotlib.dll")
    If hLib <> 0 Then
        ' If LoadLibrary finds the DLL, then so will VB.NET, so there's
        ' no need to look in the registry or change the current
        ' directory
        FreeLibrary(hLib)
        Exit Sub
    End If

    key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\DPLOT\\DPLOTLIB\\Folder")
    path = key.GetValue("").ToString()
    key.Close()
    If Len(path) > 0 Then
        System.Environment.CurrentDirectory = path
    End If
End Sub


Recently I migrated to VB 2008 but the code does not run anymore; it stops in the line:

Code:
path = key.GetValue("").ToString()


and reports the following message:

Code:
System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."


and recommends to:

Code:
Use the "new" keyword to create an object instance.


Has somebody reported the same problem with VB 2008 ?

Thanks.

Mao
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


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

PostPosted: Thu Jul 08, 2010 6:58 pm    Post subject: Reply with quote

I'm not sure but it seems to me the error message means that the key doesn't exist, and you need to check against it being "Is Nothing" before using GetValue. But I may be wrong.

You'll likely have much better luck posting this question on any of the numerous VB boards, since it really has nothing to do with DPlot.
_________________
David Hyde
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
BillGrissom



Joined: 17 Feb 2011
Posts: 4

PostPosted: Thu Feb 17, 2011 2:54 pm    Post subject: Reply with quote

Mao,

I converted a VB6 program that calls Dplot to VB2008 over 1 year ago. I didn't changed anything in sub Dplot_FindDPLOTLIB and I don't see that the auto-converter changed anything.

Anyway, I copied your lines next to mine and see no difference.

I agree that most likely your dll became unregistered. Try typing the following in a CMD window:

regsvr32 /u dplotlib.dll
regsvr32 dplotlib.dll

The first unregisters the dll (if it finds it) and 2nd registers it.
Don't ask me how it knows where to put it in the Registry, that must be embedded within the dll. This has worked for me several times, even when basic Windows dll's get unregistered (maybe a mistaken script that my I.S. department ran).
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


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

PostPosted: Thu Feb 17, 2011 3:07 pm    Post subject: Reply with quote

I'm probably in over my head here, but to the best of my knowledge regsvr32 is only useful for COM objects, and dplotlib.dll does not use COM. If I go to the folder containing dplotlib.dll with a command prompt and type
regsvr32 dplotlib.dll
I get an error message about DLLRegisterServer and whether the DLL uses OCX (it doesn't).

Short version: whatever problem BillGrissom is having is almost certainly not due to using/not using regsvr32.
_________________
David Hyde
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
BillGrissom



Joined: 17 Feb 2011
Posts: 4

PostPosted: Fri Aug 19, 2016 12:45 pm    Post subject: Reply with quote

Old post. I just ran across this.

I didn't mean to imply that I ever used the regsvr32 commands on any Dplot files, and indeed never had the issues the OP is having. I have used that command to fix another app (Pacific Instruments), per their suggestions and works there. Perhaps they use COM. I just threw it out as a simple thing to try. Sounds like it isn't relevant to Dplot.
Back to top
View user's profile Send private message
BillGrissom



Joined: 17 Feb 2011
Posts: 4

PostPosted: Fri Aug 19, 2016 12:45 pm    Post subject: Reply with quote

Old post. I just ran across this.

I didn't mean to imply that I ever used the regsvr32 commands on any Dplot files, and indeed never had the issues the OP is having. I have used that command to fix another app (Pacific Instruments), per their suggestions and works there. Perhaps they use COM. I just threw it out as a simple thing to try. Sounds like it isn't relevant to Dplot.
Back to top
View user's profile Send private message
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