I have a WinForm UserControl that I am hosting in an ASP.NET web page. In
the UserControl, I am trying to load an image into a GDI Image object using
HttpRequest.

The problem that I am having is after instantiating the HttpRequest object,
I call the GetResponse method of the request. Right after this call, all
code that follows is skipped. No exception is thrown. I can't understand
what is happening here. Can someone help?

Example:

void LoadImage()
{
UriBuilder ImageUri = new UriBuilder(http://MySite/MyImage.jpg);
WebRequest Request;
WebResponse Response;
Bitmap Img;

try
{
Request = new WebRequest(ImageUri.Uri);
Response = Request.GetResponse();

// This is line is skipped and we immediately exit the function
Img = new Bitmap(Response.GetResponseStream());
}
catch(Exception Ex)
{
String Msg = Ex.Message; // I never get an exception.
Breakpoint is never hit.
}
}



--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------

Re: Having problems with loading data using WebRequest. by Bryan

Bryan
Thu Nov 10 11:13:50 CST 2005

Hi Ken,
I have done some extensive development with IE hosted controls. I have found
that the .net framework is very picky about security when it comes to this,
sometimes no security exception is thrown. Could it be you are trying to
access the file system on the PC? Another thing to do is put the
InitializeComponent in a try-catch, this will catch all errors.

Bryan


"Ken Varn" <nospam> wrote in message
news:%236tZXug5FHA.1464@tk2msftngp13.phx.gbl...
>I have a WinForm UserControl that I am hosting in an ASP.NET web page. In
> the UserControl, I am trying to load an image into a GDI Image object
> using
> HttpRequest.
>
> The problem that I am having is after instantiating the HttpRequest
> object,
> I call the GetResponse method of the request. Right after this call, all
> code that follows is skipped. No exception is thrown. I can't understand
> what is happening here. Can someone help?
>
> Example:
>
> void LoadImage()
> {
> UriBuilder ImageUri = new UriBuilder(http://MySite/MyImage.jpg);
> WebRequest Request;
> WebResponse Response;
> Bitmap Img;
>
> try
> {
> Request = new WebRequest(ImageUri.Uri);
> Response = Request.GetResponse();
>
> // This is line is skipped and we immediately exit the function
> Img = new Bitmap(Response.GetResponseStream());
> }
> catch(Exception Ex)
> {
> String Msg = Ex.Message; // I never get an exception.
> Breakpoint is never hit.
> }
> }
>
>
>
> --
> -----------------------------------
> Ken Varn
> Senior Software Engineer
> Diebold Inc.
>
> EmailID = varnk
> Domain = Diebold.com
> -----------------------------------
>
>



Re: Having problems with loading data using WebRequest. by Ken

Ken
Fri Nov 11 07:54:46 CST 2005

It seemed to be related to the location of the call. I had it in a public
property and then moved it into its own function. After doing this, I was
able to intercept the exception in the debugger. Strange.

Turns out it was a security exception.

I am just starting to get my feet wet in this area with web hosted winform
controls. If you know of any good reference materials, please let me know
where I can find them.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"Bryan" <BryanZM@nospam.nospam> wrote in message
news:e%23v$roh5FHA.3292@tk2msftngp13.phx.gbl...
> Hi Ken,
> I have done some extensive development with IE hosted controls. I have
found
> that the .net framework is very picky about security when it comes to
this,
> sometimes no security exception is thrown. Could it be you are trying to
> access the file system on the PC? Another thing to do is put the
> InitializeComponent in a try-catch, this will catch all errors.
>
> Bryan
>
>
> "Ken Varn" <nospam> wrote in message
> news:%236tZXug5FHA.1464@tk2msftngp13.phx.gbl...
> >I have a WinForm UserControl that I am hosting in an ASP.NET web page.
In
> > the UserControl, I am trying to load an image into a GDI Image object
> > using
> > HttpRequest.
> >
> > The problem that I am having is after instantiating the HttpRequest
> > object,
> > I call the GetResponse method of the request. Right after this call,
all
> > code that follows is skipped. No exception is thrown. I can't
understand
> > what is happening here. Can someone help?
> >
> > Example:
> >
> > void LoadImage()
> > {
> > UriBuilder ImageUri = new UriBuilder(http://MySite/MyImage.jpg);
> > WebRequest Request;
> > WebResponse Response;
> > Bitmap Img;
> >
> > try
> > {
> > Request = new WebRequest(ImageUri.Uri);
> > Response = Request.GetResponse();
> >
> > // This is line is skipped and we immediately exit the function
> > Img = new Bitmap(Response.GetResponseStream());
> > }
> > catch(Exception Ex)
> > {
> > String Msg = Ex.Message; // I never get an exception.
> > Breakpoint is never hit.
> > }
> > }
> >
> >
> >
> > --
> > -----------------------------------
> > Ken Varn
> > Senior Software Engineer
> > Diebold Inc.
> >
> > EmailID = varnk
> > Domain = Diebold.com
> > -----------------------------------
> >
> >
>
>