.net - Why does my custom HttpResponse throw exception on HttpResponse.End()? -


i'm writing code in need use own httpresponse object capture output method on object takes httpresponse parameter. problem is, other object (which cannot modify) calls httpresponse.end(), causes "object reference not set instance of object" exception thrown. can this?

dim mystringbuilder new stringbuilder dim mystringwriter new io.stringwriter(mystringbuilder) dim myresponse new web.httpresponse(mystringwriter)  someobject.dostuffwithhttpresponse(myresponse) ' calls myresponse.end() , crashes 

here's more complete information error, thrown following code in console application:

dim mystringbuilder new stringbuilder dim mystringwriter new io.stringwriter(mystringbuilder) dim myresponse new web.httpresponse(mystringwriter) try  myresponse.end() catch ex exception  console.writeline(ex.tostring) end try 

here's text of exception:

system.nullreferenceexception: object reference not set instance of object. @ system.web.httpresponse.end() @ consoleapplication1.module1.main() in c:\documents , settings\joe.user\local settings\application data\temporary projects\consoleapplication1\module1.vb:line 10

response.end() failing because not in asp.net environment, in console/other non-asp.net application. guess (and confirmed cheating , using reflector) response.end references httpcontext.current (or equivelant local copy), null, throws error.

calling response.end kind of mean of other code. know can't change should calling response.flush if it's worried.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -