Problem reading resource stream in ASP.Net

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
 
B

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"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top