homebrew311 Posted February 25, 2004 Posted February 25, 2004 Every time I make a DLL and try to use it, the host program always returns a "Object reference not set to the instance of an object" error. What am I doing wrong? Quote
Administrators PlausiblyDamp Posted February 25, 2004 Administrators Posted February 25, 2004 Could you show some code? It sounds like you are not setting a variable to a valid instance of an object... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
homebrew311 Posted February 25, 2004 Author Posted February 25, 2004 Dll code Public Class Class1 Public Function Bob(ByVal int1 As Integer, ByVal int2 As Integer) As String Dim Ans As Integer Ans = int1 + int2 Return Ans End Function End Class Button procedure Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click Dim DLL As Dll_Test_Dll.Class1 MsgBox(DLL.Bob(1, 2)) End Sub Quote
Administrators PlausiblyDamp Posted February 25, 2004 Administrators Posted February 25, 2004 try the following... Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click Dim DLL As New Dll_Test_Dll.Class1 'change this line MsgBox(DLL.Bob(1, 2)) End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
bri189a Posted February 25, 2004 Posted February 25, 2004 you need the new keyword... at least in C# you would, probably the same for VB... Dim DLL as New Dll_Test_Dll.Class1 Quote
homebrew311 Posted February 25, 2004 Author Posted February 25, 2004 Yeah I got it now. Thanks a lot guys. Quote
Heiko Posted February 26, 2004 Posted February 26, 2004 And while you're at it, you may want to clean up Class1.Bob as well, because the signature claims to return a sting, but in the code you return an integer. :) Quote .nerd
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.