Re: How to access and use Unmanaged Code

Tech-Archive recommends: Fix windows errors by optimizing your registry



Chris

Thanks for the reply

I have managed to get past the Object reference but now I am encountering an
error when running the application.

The error I am getting is "Unable to load DLL filename"

I have tried to reference the DLL within net but can't as net does not
recognize it as a valid assembly or COM object. I know its OK as I can get
Microsoft Depends to open it and read the import/export ordinal and other
data etc.

I have tried to register it via regasm and AL neither will accept it.

I have tried putting the dll in the system folder, windows folder, along
with the default project path

Nothing seems to work.

To investigate further I created a simple fortran function to add two
integers and reference it using the using the declare statement in VB. The
same exact problem results - unable to load DLL during execution.

I guess the issue is how do you get net to recognize a dll that was
constructed outside of net ie "unmanaged"?????????

Can you help?

Thanks

Mike C.

"Chris Dunaway" <dunawayc@xxxxxxxxx> wrote in message
news:1154007001.060395.168870@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Michael wrote:

I am trying to access external code from within VB using DLLimport in
the
form below where testsub is the procedure name within the DLL

<DllImport("MyDll.dll", EntryPoint:="testsub", SetLastError:=True, _
CharSet:=CharSet.Unicode, ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Sub _
Test(ByVal JOB As Char, ByRef A(,) as Double)

When calling the routine from VB.Net I keep on getting an "Object
reference
not set to instance object" error


Can you post the stack trace when you get that exception? Where does
the error occur? Can you debug the app and step through the code to
find the line where the exception is thrown?



.



Relevant Pages

  • Global Assembly Cache Issue
    ... I have a dll that I use in several projects, that I placed in the Global ... you can see in the Exception below). ... If I change the Copy Local property of the reference to True, ... Attempting download of new URL ...
    (microsoft.public.dotnet.framework.aspnet)
  • VB FAQs (Interview Questions) lot lot
    ... Consider two objects, A and B. A holds a reference to B, ... Why do so many example programs not use the DLL name ... Private Declare Function SendMessage Lib "user32" ... Private Const BUFFER_LENGTH As Long = 255 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Sharing Code
    ... What I found would happen is that when the device dll was built visual ... In the desktop project when you add a reference to the dll, ... > projects, one smart device and one desktop, but they're in the same ... > The 2 form projects have references to this class library projects. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Namespaces - broad question
    ... Reference the Class Library in your Page, ... > aspx pages that I know I want utilize a specific function within, ... > have the same codebehind page), how can I reference this function. ... >> A .Net assembly is a compiled DLL. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Namespace Question
    ... >>i saw that when i changed it to true my dll was copied to the bin folder ... >>the reference by looking in the following locations, ... Look for assemblies in directories specified with the Reference Path ... >> tried to use the GAC but the process to convert dll to be strong name ...
    (microsoft.public.dotnet.languages.vb)