Win32 Exception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jake Pearson

    Win32 Exception

    Hi,
    I am getting an exception when I read in bunch of resources with the
    following code:

    string fullName = name + ".ico";
    Stream stream = assembly.GetMan ifestResourceSt ream(fullName);
    return new Icon(stream);

    The stack trace is as follows:

    Unhandled Exception: System.Componen tModel.Win32Exc eption: Element not
    found
    at System.Drawing. Icon.Initialize (Int32 width, Int32 height)
    at System.Drawing. Icon..ctor(Stre am stream)

    It seems to only happen when I read the same resource again and again.
    I was able to fix the error by caching the resource, but I was still
    curious why it happens. Any ideas?

    thanks,
    Jake Pearson
  • Robert Misiak

    #2
    Re: Win32 Exception

    Jake-

    Try adding the name of the default namespace to the beginning of the string:

    string fullName = "NameSpace. " + name + ".ico";

    Robert



    "Jake Pearson" <jpearson@maad. com> wrote in message
    news:52f59708.0 406161152.131d9 5e4@posting.goo gle.com...[color=blue]
    > Hi,
    > I am getting an exception when I read in bunch of resources with the
    > following code:
    >
    > string fullName = name + ".ico";
    > Stream stream = assembly.GetMan ifestResourceSt ream(fullName);
    > return new Icon(stream);
    >
    > The stack trace is as follows:
    >
    > Unhandled Exception: System.Componen tModel.Win32Exc eption: Element not
    > found
    > at System.Drawing. Icon.Initialize (Int32 width, Int32 height)
    > at System.Drawing. Icon..ctor(Stre am stream)
    >
    > It seems to only happen when I read the same resource again and again.
    > I was able to fix the error by caching the resource, but I was still
    > curious why it happens. Any ideas?
    >
    > thanks,
    > Jake Pearson[/color]


    Comment

    • Robert Misiak

      #3
      Re: Win32 Exception

      Jake-

      Try adding the name of the default namespace to the beginning of the string:

      string fullName = "NameSpace. " + name + ".ico";

      Robert



      "Jake Pearson" <jpearson@maad. com> wrote in message
      news:52f59708.0 406161152.131d9 5e4@posting.goo gle.com...[color=blue]
      > Hi,
      > I am getting an exception when I read in bunch of resources with the
      > following code:
      >
      > string fullName = name + ".ico";
      > Stream stream = assembly.GetMan ifestResourceSt ream(fullName);
      > return new Icon(stream);
      >
      > The stack trace is as follows:
      >
      > Unhandled Exception: System.Componen tModel.Win32Exc eption: Element not
      > found
      > at System.Drawing. Icon.Initialize (Int32 width, Int32 height)
      > at System.Drawing. Icon..ctor(Stre am stream)
      >
      > It seems to only happen when I read the same resource again and again.
      > I was able to fix the error by caching the resource, but I was still
      > curious why it happens. Any ideas?
      >
      > thanks,
      > Jake Pearson[/color]


      Comment

      Working...