DLL Question
-
I am converting a vb6 project to .net, slowly but surely. If the VB6 project I had a DLL we wrote, I add a reference in the VB6 program and wala I could use it. I tried a similar thing in .net but I get a "Object reference not set to an instance of an object." when I try to call something in the dll. I am not sure how to properly do this in VS2008, do I need to do some additional initialization? How would I do it if I wanted to debug the code of the DLL when I am running the secondary project? in VB6 I could point a reference to the VB project for the DLL, not sure how to do that either. If it not a quick answer, can any one point me to a tutorial of some nature? Not quite what to google...
-
I am converting a vb6 project to .net, slowly but surely. If the VB6 project I had a DLL we wrote, I add a reference in the VB6 program and wala I could use it. I tried a similar thing in .net but I get a "Object reference not set to an instance of an object." when I try to call something in the dll. I am not sure how to properly do this in VS2008, do I need to do some additional initialization? How would I do it if I wanted to debug the code of the DLL when I am running the secondary project? in VB6 I could point a reference to the VB project for the DLL, not sure how to do that either. If it not a quick answer, can any one point me to a tutorial of some nature? Not quite what to google...
Without seeing the code that's throwing the exception, it's pretty difficult to tell you what went wrong. But, you only get that message when you try to use a variable that contains null (Nothing in VB). The whole process is really not very different than it was in VB6.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
I am converting a vb6 project to .net, slowly but surely. If the VB6 project I had a DLL we wrote, I add a reference in the VB6 program and wala I could use it. I tried a similar thing in .net but I get a "Object reference not set to an instance of an object." when I try to call something in the dll. I am not sure how to properly do this in VS2008, do I need to do some additional initialization? How would I do it if I wanted to debug the code of the DLL when I am running the secondary project? in VB6 I could point a reference to the VB project for the DLL, not sure how to do that either. If it not a quick answer, can any one point me to a tutorial of some nature? Not quite what to google...
Assuming your DLL contains native code, you would need P/Invoke to call that from a managed language such as C# or VB.NET; here is an article that should get you on the right track: pinvoke1[^]. I suggest you start with the simplest call available in the DLL, and learn the techniques step by step. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum