|
Yes, that would take care of those.
---
single minded; short sighted; long gone;
|
|
|
|
|
Ben[dog] wrote: Bitmap b = (Bitmap) Cache[CacheKey];
This is not a leak, as it's in your cache, you don't want to dispose of it.
The easy way to write code that makes clear that yo dispose of resources is a using block
using (BItmap bm = Bitmap.FromFile(path))
{
// do stuff with bm here
} // bm.Dispose is automatically called here.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: The easy way to write code that makes clear that yo dispose of resources is a using block
I agree this is often a neat way to do it, though a bit tiresome with GDI+ as there's so many objects created you need to wrap too many using() statements within another, making it a bit hard to move code around or re-arrange things...
But if the individual Dispose() are explicitely called, that shouldn't really make a difference, should it?
Ben
|
|
|
|
|
No, it simply gives you a way to see easily that they are going to be called. I didn't track through all your code, but Guffa said he found two items that were not.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: Guffa said he found two items that were not.
Yes, I replied to him, actually one one of them was not disposed, the other is kept in the cache so shouldn't be disposed.
Anyway, thanks for your help, I appreaciate it.
I will do more testing with that last object disposed and see what happens.
Cheers
Ben
|
|
|
|
|
Ben[dog] wrote: But if the individual Dispose() are explicitely called, that shouldn't really make a difference, should it?
Yes, there is a difference.
The using statement makes a copy of the reference and creates a try...finally block, which ensures that the Dispose method is called no matter what happens in the code.
If you just call Dispose, it will depend on two things: that the code is not interrupted before that and that the reference is still valid at that point.
---
single minded; short sighted; long gone;
|
|
|
|
|
Aaaah, cool.
That's interesting. Thanks for that explanation, makes plenty of sense. I'll see to convert my label-thingie to that.
You should be a writer for the MSDN, they've got some trouble making things that clear.
Ben
|
|
|
|
|
Side question to this thread:
is
MemoryStream io = new MemoryStream();
tmpBitmap.Save(io, Format);
Response.BinaryWrite(io.ToArray());
io.Close();
The most appropriate way to send the image to the output stream?
i've seen variations of this elsewhere.. wondering if there is the right way, and the right way
|
|
|
|
|
I had this working in my project, then I wanted to use this code in another project and now it refuses to save a BMP file.
Please someone tell my what I overlook.
Ranger.
float range = 1.5F;
float startRe = -0.7F;
float startIm = 0.27015F;
int startColor = 60;
public Bitmap objBitmap = new Bitmap(300, 300);
public Graphics objGraphic;
public Pen myPen = new Pen(Color.Red);
protected void enterButton_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
objGraphic = Graphics.FromImage(objBitmap);
MakeJuliaSetBmp(); // Do the drawing
Response.ContentType = "image/bmp";
MakeUniqueFileName(); // makes a unique filename for the BMP file
objBitmap.Save(Request.PhysicalApplicationPath + "/pictures/" + filename, ImageFormat.Bmp);
Response.Flush();
objGraphic.Dispose();
objBitmap.Dispose();
myPen.Dispose();
}
}
Novice
|
|
|
|
|
Ranger49 wrote: now it refuses to save
What do you mean? An exception is thrown? The files isn't created? Are you sure the proper rights have been assigned to the destination folder?
only two letters away from being an asset
|
|
|
|
|
Ranger49 wrote: public Bitmap objBitmap = new Bitmap(300, 300);
public Graphics objGraphic;
public Pen myPen = new Pen(Color.Red);
Why are these public ? Why are they members at all ?
Ranger49 wrote: MakeUniqueFileName
Why does this not return the filename ?
It's probable you don't have write permissions on the folder, or it doesn't exist. Hard to say without seeing the error
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
The problem is that the enterButton_Click method (which should call a class to compute a fractal which then saves it to a Bmp pic file) never runs. Also my codefile in the App_Code ProduceImageFile.cs never is even run.
I wanted the enter.aspx to call the ProduceImageFile.cs but somehow that never happens.
In enter.aspx is a startButton_Click method which also never seems to fire, even though it does move you to the display.aspx which is intended to display the computed picture, the wanted calculations are never made on this click.
So there may not be any bugs in the code where I expected it, this code never is reached and executed!
About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it?
Hope this is clearer now.
Thanks everybody.
Ranger.
Novice
|
|
|
|
|
Ranger49 wrote: About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it?
No.
How are the buttons hooked up to events ? If they are created on the fly, they need to be created in the LoadViewState event, so that they exist when view state is restored, and their events are not lost.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: How are the buttons hooked up to events ?
I only got a enterButton_Click method.
Is there a LoadViewState event in the properties window of the button? I couldn't find it.
Ranger.
Novice
|
|
|
|
|
As it turned out the code was never even reached.
So I made an instance of the class that should generate a bmp file in the Page_Load handler of my enter.aspx.
Now it did run, but now I get the message:
Response.ContentType = "image/bmp"; not available in this context...! Which is the ProduceImageFile.cs (a class file)I checked all using statements, and I think I got all the ones I need.
When you type R you get Response and then you type '.' and C and get Response.ContentType, so I feel this should be available, but for some reason I get an exception that my application cannot handle the
Response.ContextType = "image/bmp"; statement.
Could anybody tell me how to fix this? It is kind of frustrating to have to spend days on simple things that don't want to work, simply because all those online help files only address the hard issues.
I tried these concepts in small projects and got them to run properly, then I tried to encorporate them in a larger application and again it refuses to function!
Ranger.
Novice.
|
|
|
|
|
how can I send email via asp.net 1.1 and C# and sqlserver2000?
I dont know how should I write for mail.smtpserver
plz tell me.
thanks alot. bye
|
|
|
|
|
Do you know the mail server you want to use ? If not, check your outlook settings.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
using System.Web.Mail;
#region SendMail
public bool SendMail(string TargetEmailAddress,string MessageBody)
{
try
{
MailMessage mailMsg = new MailMessage();
mailMsg.To = TargetEmailAddress;
mailMsg.From = "AnyEmailAddress";
mailMsg.Subject = "Subject Of Email";
mailMsg.BodyFormat = MailFormat.Html;
mailMsg.BodyEncoding = Encoding.UTF8;
mailMsg.Body = MessageBody;
SmtpMail.Send(mailMsg);
return true;
}
catch
{
return false;
}
}
#endregion
We Can Do Anything, If We Want It
|
|
|
|
|
Hi,
I have 2 web application hosted on 2 separate servers.In first application i had one anchor tag whose target=_None and href="url of 2nd application"
Is it possible to access the cookie which is created by first application in second application ? if yes how?
Any help on this.........
Regards,
Ritesh
|
|
|
|
|
I want to have a website with two sections; Admin and user section . How can I have two cookie path for authenticating purpose. As you might know we sepcify a path in web.config file for cookie path.
<forms name=".SiteAUTH" protection="All" timeout="120" path="/">
<credentials passwordformat="SHA1">
Is it neccessary for me to have two paths for the two section . How is this possible ?
What I want is to have to kind of users ; administrators and normal users .
|
|
|
|
|
Hi, I'm Tring to pass a String Parameter From .Net Application to .Net ASP Web Service.
I'm Sending A Valid String but the web service Gets Null String insted of the string that i've sent to it.
I must say that this same Web function Has another parameter, of inteter
type, and that this parameter is passing OK with the right value.
Thaks Ram.
|
|
|
|
|
Did you try creating a test web method and pass it the same string in the same method your currently using?
Outside of this, did you test your web service itself with good/known values?
|
|
|
|
|
Passing a string to a web service is nothing complicated. Actually, all values are passed as strings, so when you pass an integer value, it's converted to a string, sent to the web service, and converted back to an integer.
The most likely reasons for this to fail, is either that you are doing something wrong when passing the string value to the web service, or doing something wrong when using the value in the web service.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello!
I use Visual Web Developer with IE6 (because my PC won't accept IE7) and today I was working on my projct and that suddenly I no longer got the question "run with debugging?"
I saw a message that in Internet Options (I assume of IE) I should remove a check from a box with 'Disable debugging'. Now I have a Dutch IE6 so I couldn't find the box, but I did remove a check from a box with 'disable script debugging' from it. But that didn't help.
It puzzles me that during the last week I often used the debugging mode with breakpoints and that everything worked fine and now I can no longer halt VWD with a breakpoint!
What do I do now?
Btw, my project is going really well, but all this is new to me, so I have yet to find out why certain code won't do what I want.
Please provide me with some advice.
Ranger.
Novice.
|
|
|
|
|
go yo web.config
change this line
<compiation>
to this
<compiation debug="true">
i hope this will help
|
|
|
|