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
  1. Home
  2. General Programming
  3. C#
  4. An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll in c#

An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll in c#

Scheduled Pinned Locked Moved C#
helpquestioncsharp
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.
  • R Offline
    R Offline
    ramyanaidu
    wrote on last edited by
    #1

    Hi I have classes property and sketch in htis property will be linked to skecth class and foure different classes which r linked to the skecth class and two generic list one is for skecth and other is for data of type Object when i run the program i iam grtting the error here public Sketch FirstData() { // return Datas[Datas.Count]; foreach (Object data in Datas) { if (data is Door) { Door door = (Door)data; } if (data is Fixture) { Fixture fixture = (Fixture)data; } if (data is Wall) { Wall wall = (Wall)data; } if (data is Window) { Window window = (Window)data; } //return } return getSketch(1); } private Sketch getSketch(Int32 id) { foreach (Object data in Datas) { if (data is Door) { Door door = (Door)data; door.Id = id; } if (data is Fixture) { Fixture fixture = (Fixture)data; fixture.Id = id; } if (data is Wall) { Wall wall = (Wall)data; wall.Id = id; } if (data is Window) { Window window = (Window)data; window.Id = id; } } return getSketch(id); } An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll how can i slove this problem? can any one help me in this

    M 1 Reply Last reply
    0
    • R ramyanaidu

      Hi I have classes property and sketch in htis property will be linked to skecth class and foure different classes which r linked to the skecth class and two generic list one is for skecth and other is for data of type Object when i run the program i iam grtting the error here public Sketch FirstData() { // return Datas[Datas.Count]; foreach (Object data in Datas) { if (data is Door) { Door door = (Door)data; } if (data is Fixture) { Fixture fixture = (Fixture)data; } if (data is Wall) { Wall wall = (Wall)data; } if (data is Window) { Window window = (Window)data; } //return } return getSketch(1); } private Sketch getSketch(Int32 id) { foreach (Object data in Datas) { if (data is Door) { Door door = (Door)data; door.Id = id; } if (data is Fixture) { Fixture fixture = (Fixture)data; fixture.Id = id; } if (data is Wall) { Wall wall = (Wall)data; wall.Id = id; } if (data is Window) { Window window = (Window)data; window.Id = id; } } return getSketch(id); } An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll how can i slove this problem? can any one help me in this

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, The problem is that you call "getSketch(id)" recursive! "return getSketch(id);" You will never come out of this method. I'm not sure what this program should do, but I have the feeling that the "getSketch" method should somewhere instanciate a "Sketch" object and return this one. Apart from that you should really work with interfaces, as you have to check four types and write at the same param. Hope it helps!

      All the best, Martin

      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