Problem reading resource stream in ASP.Net

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I'm having a problem reading a resource stream using the following syntax:

Dim resStream As System.IO.TextReader = New _

System.IO.StreamReader(Me.GetType.Assembly.GetManifestResourceStream("myname
space.script.js"))

I receive the error: Value cannot be null. Parameter name: stream

I think the underlying problem is that the name of the assembly
(Assembly.FullName) appears to be some kind of temporary name at run time.
For example, this is what Assembly.FullName looks like at runtime:
"si2y4pl3, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null" String

The code is in an assembly which contains a base class I've written for
ASP.NET pages (class inherits from System.Web.UI.Page). I reference this
assembly in a web project and aspx pages inherit from the base class I
created.


Brad
 
Found the problem.
Changed from

System.IO.StreamReader(Me.GetType.Assembly.GetManifestResourceStream("myname
space.script.js"))
to
Dim asm As [Assembly] = [Assembly].GetExecutingAssembly()
New
System.IO.StreamReader(asm.GetManifestResourceStream(asm.GetName.Name &
".script.js"))
 
Back
Top