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. Web Development
  3. ASP.NET
  4. assembly error

assembly error

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-net
2 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.
  • S Offline
    S Offline
    saqib82
    wrote on last edited by
    #1

    Hi I am trying to access a dll in asp.net/c# but when i try to initialize the object of the class in that dll, i get the following error: "Object reference not set to an instance of an object" I have added the assembly using this line: using assemblyname; I am creating object with statement like that: ReportAccess ra = new ReportAccess(); // i get error on the same line. Can someone help me please by providing me the solution of that problem or by letting me know why i am getting this error or what are the reasons for that error. Regards

    sAqIb "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.

    S 1 Reply Last reply
    0
    • S saqib82

      Hi I am trying to access a dll in asp.net/c# but when i try to initialize the object of the class in that dll, i get the following error: "Object reference not set to an instance of an object" I have added the assembly using this line: using assemblyname; I am creating object with statement like that: ReportAccess ra = new ReportAccess(); // i get error on the same line. Can someone help me please by providing me the solution of that problem or by letting me know why i am getting this error or what are the reasons for that error. Regards

      sAqIb "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.

      S Offline
      S Offline
      Sathesh Sakthivel
      wrote on last edited by
      #2

      saqib82 wrote:

      what are the reasons for that error.

      (1) Common mistake when working with code behind classes. Remember! Codebehinds arn't handled the same way as inline/ pages! You need to declare EVERY control you want to interact with in the codebehind class Do this just after the Inherits statement: <code>Public Class PageOne Inherits System.Web.UI.Page Protected WithEvents litOne As System.Web.UI.WebControls.Literal ...</code> (2) Bad Scoping. <code>Sub Page_Load(ByVal e As System.EventArgs) Handles MyBase.Load Private strHello As String End Sub Sub Button1_Click(ByVal e As System.EventArgs) Handles Button1.Click strHello = "Hello!" End Sub</code> (3) bad inits and constructs: Remember, some classes have constuctors Consider DirectoryInfo: <code>Sub Page_Load() .... Dim dirInfo As System.IO.DirectoryInfo dirInfo.GetDirectory("C:\") End Sub</code> In the above example, we've only defined dirInfo *AS* a DirectoryInfo class, we haven't actually created it So we need to do this instead: <code>Sub Page_Load() .... Dim dirInfo As System.IO.DirectoryInfo dirInfo = New System.IO.DirectoryInfo("C:\") End Sub</code> That should do it.... Remember, ALWAYS refer to the MSDN Library when enquiring about classes and their initilisation (sp?) methods.... why trust some "1337 script kiddie!" site when you've got the official reference at http://www.msdn.com ? Or better yet, get the compiled version on CD, don't need to worry about long download times or the constant "was this article of any use to you?" screen. HTH -1337_d00d <div class="ForumSig">SSK.</div></x-turndown>

      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