Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. HELP! Errors while attempting to import a DLL

HELP! Errors while attempting to import a DLL

Scheduled Pinned Locked Moved Visual Basic
helpcsharpdotnetvisual-studio
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    b_girl
    wrote on last edited by
    #1

    Hey, I'm new to VB.NET (and have no experience programming in VB) - I tried to post earlier but for some reason it didn't work, and the second attempt is never as good as the first! I'm using Visual Studio 2005 with .NET Framework 2.0. Anyway, in my project I have a need to call rasapi32.dll, from what I understand I need to use an unmanaged code block in order to make use of this DLL. This is what I have so far: Imports System.Runtime.InteropServices Public Class TestRASDial <DllImport("rasapi32.dll", CharSet:=CharSet.Auto)> _ Public Function RasDial(ByVal LPRASDIALEXTENSIONS, _ ByVal LPCTSTR, _ ByVal LPRASDIALPARAMS, _ ByVal DWORD, _ ByVal LPVOID, ByVal LPHRASCONN) As Long End Function End Class Now, I realize this doesn't actually do anything just yet, but I need to get the basics working first. So, the above bit of code gives me the following error: "System.Runtime.InteropServices.DllImportAttribute' cannot be applied to instance method." The word "RasDial" is underlined so I'm assuming that's the problem, however, I don't know how else to do this. I've tried searching online but can't seem to find much on the topic for some reason. I would really appreciate it if any of you are able to help me out and point out what I've done wrong! You'd be a lifesaver... Thanks a million...

    P 1 Reply Last reply
    0
    • B b_girl

      Hey, I'm new to VB.NET (and have no experience programming in VB) - I tried to post earlier but for some reason it didn't work, and the second attempt is never as good as the first! I'm using Visual Studio 2005 with .NET Framework 2.0. Anyway, in my project I have a need to call rasapi32.dll, from what I understand I need to use an unmanaged code block in order to make use of this DLL. This is what I have so far: Imports System.Runtime.InteropServices Public Class TestRASDial <DllImport("rasapi32.dll", CharSet:=CharSet.Auto)> _ Public Function RasDial(ByVal LPRASDIALEXTENSIONS, _ ByVal LPCTSTR, _ ByVal LPRASDIALPARAMS, _ ByVal DWORD, _ ByVal LPVOID, ByVal LPHRASCONN) As Long End Function End Class Now, I realize this doesn't actually do anything just yet, but I need to get the basics working first. So, the above bit of code gives me the following error: "System.Runtime.InteropServices.DllImportAttribute' cannot be applied to instance method." The word "RasDial" is underlined so I'm assuming that's the problem, however, I don't know how else to do this. I've tried searching online but can't seem to find much on the topic for some reason. I would really appreciate it if any of you are able to help me out and point out what I've done wrong! You'd be a lifesaver... Thanks a million...

      P Offline
      P Offline
      progload
      wrote on last edited by
      #2

      The function must be shared. Public Shared Function RasDial(ByVal .... ect. hope that helps.

      B 1 Reply Last reply
      0
      • P progload

        The function must be shared. Public Shared Function RasDial(ByVal .... ect. hope that helps.

        B Offline
        B Offline
        b_girl
        wrote on last edited by
        #3

        Ahhh yes! That has gotten rid of that error... many thanks! Now just to figure the rest out... Thanks so much. :-D

        P 1 Reply Last reply
        0
        • B b_girl

          Ahhh yes! That has gotten rid of that error... many thanks! Now just to figure the rest out... Thanks so much. :-D

          P Offline
          P Offline
          progload
          wrote on last edited by
          #4

          No problem, By the way you may be interested in this, although it's in C# and in purgatory for some reason, it may help you with figuring out the calls. most of it is readily convertable to VB.Net. http://www.codeproject.com/Purgatory/rasdemo.asp?target=ras[^] http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx[^] Need any other help let me know. progload

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups