|
Yeah. I know where the article is.
The subtle point was to let you know that you need to include links like this instead of assuming the people helping out here have the time to go searching for them
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
your right. my apologies
did you need any other info?
the ICodeCompiler doesn't have any properties i can set. and the dll will be written before its assigned to the CompilerResults object.
ideally i'd like to write it to the MS temp directory.
Orion
Orion
|
|
|
|
|
Orion Buttigieg wrote:
your right. my apologies
No worries. Just saves us time.
Orion Buttigieg wrote:
the ICodeCompiler doesn't have any properties i can set. and the dll will be written before its assigned to the CompilerResults object. Ideally i'd like to write it to the MS temp directory
Actually, I've not worked through the demo and haven't needed to do what you're talking about. If nobody has figured this out by the time I get home (I'm on the way to pick up kids now), I'll look at it tonight and try and help.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
hiho,
does anyone know/has (a url to) a tutorial or some better-than-msdn-documentation on the ImageEncoder-EncoderParameters-overload of the save function? i want to be able to set the jpeg-quality, tiff-compression and all these things by hand. and to be kind: msdn-docu isn't very helpful.
thx in advance
:wq
|
|
|
|
|
ups! i did find something in msdn - somewhere deep inside is a little example that helps me.
:wq
|
|
|
|
|
Curiosity !
Has anyone had any problem with unmanaged resources like handles etc ?
Or Is the garbage collection catching them all ?
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
More about me
|
|
|
|
|
Colin Davies wrote:
Has anyone had any problem with unmanaged resources like handles etc ?
What do you mean by that? If you are writing a C# program, everything is managed. You can't access an unmanaged resource. Unless you meant something else.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
An unmanaged resource is a file, database connection, HPEN, HDC, HBITMAP, etc... There are wrappers around all of those resources each providing you with a Dispose method which will free the handle; in the case of Files and Database Connections you have appropriate Close methods you can call as well.
James
Simplicity Rules!
|
|
|
|
|
Thanks James. But my idea was that Dispose is automatically called. I wasn't aware that we need to call it manually. Unless we are talking of our own wrapper class.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
My issue is what happens on exit ?
Since the poointer is hadling the addresses on the stack where will it be left ?
Then what happens if I run a new instance of the App ?
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
More about me
|
|
|
|
|
Irrespective of whether it's a .NET app or an unmanaged Win32 app, when a process terminates, all resources are freed.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Dispose isn't automatically called; the Finalize method is, at some point in time.
For handling nonmanaged resources Microsoft has come up with the Dispose pattern, classes that work with nonmanaged resources are supposed to implement IDisposable (only method is Dispose).
In side that the managed resources are released and the object should throw an exception if an attempt is made to use that instance again. Also inside of the Dispose method you should call GC.SuppressFinalize(this); so that the finalizer doesn't get called (no need since you already freed your resources). The finalizer is supposed to just call Dispose.
Confused yet?
Enter the using construct. With it you can specify that an object will have its Dispose method called automatically.
using(Graphics g = CreateGraphics())<br />
{<br />
}
Roughly translates to
Graphics g = CreateGraphics();<br />
try<br />
{<br />
}<br />
finally<br />
{<br />
((IDisposable) g).Dispose();<br />
}
Simplicity Rules!
|
|
|
|
|
Thanks a LOT James. I sorta understand now
Man, I wrote all that code and I never knew about all this inside stuff.
I feel a little silly
Nish
p.s, CG was telling us to stop bothering you with questions, so you can finish the saver
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Nish [BusterBoy] wrote:
p.s, CG was telling us to stop bothering you with questions, so you can finish the saver
LOL, yeah I was busy writing my first reply when I was supposed to be seeing why the drawing didn't speed up even though my test program shows ~80% increase in drawing
James
Simplicity Rules!
|
|
|
|
|
In WinForms there is a resource manager that is supposed to keep track of the resources for you, but I think its best practice to call free up resources right away.
If there is a managed wrapper for the resource just call Dispose on it to do that; else you'll have to dispose of it yourself.
James
Simplicity Rules!
|
|
|
|
|
Thanks Mr Johnson,
I realised about the Dispose, but what happens if I don't use it and the user exits the App.
Is there a resource leak ?
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
More about me
|
|
|
|
|
As I understand it, if you used objects handled by the Resource Manager it will free those for you; ones that aren't handled by it will get free'd if and only if their finalize method frees them.
James
Simplicity Rules!
|
|
|
|
|
does anyone know how to create this file (app.config) when working with winforms(it's similar to the web.conf in asp.net)? This file gets created with some projects but not others and I was not paying attention when it got create. I just noticed it one day and started adding keys to hold my connection string. But now I need to know how to create this file and I don't know how.
|
|
|
|
|
Whooya!!! This one took me forever to figure it out. Basically, select a control. Then select its properties. For most controls you will have either DataBinding or DynamicProperties section on the properties list. Go into Advance and select the items you want to place in the config file. An app.config file will automatically be generated.
|
|
|
|
|
You can create MyApp.exe.config in the same directory where your app resides,
and than use System.Configuration.ConfigurationSettings to read the configuration file app settings.
Config file example:
<configuration>
<appSettings>
<add key="Database" value="MyDB" />
<add key="Username" value="code" />
<add key="Password" value="project" />
</appSettings>
</configuration
-Gile
|
|
|
|
|
I've found this topic not well documented.. actually, I was playing with Custom Configuration Handlers, but it's related.
Ok, to the point , every time you compile your program using Visual Studio .NET it will look for a file named app.config, if the file exists, it will create an output file on your destination directory (Release or debug for example) with the following name:
<ApplicationName>.exe.config
This file will contain the data you put on app.config.
Be aware that this file will be recreated everytime you compile your program (this got me for a while), so if you change the output config file, the changes will be lost on your next recompile.
If you need to change the config file during development, change app.config, you are going to see these changes reflected on your output file.
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Ok, I know this must be a really dumb question, but how do I add an image to my project in Visual Studio.NET so that I can reference it in code such as "myPicture.jpg" . Thanks again, don't laugh too much
Nick Parker
|
|
|
|
|
So such thing as a dumb question
Right click on the project and choose Add Existing Item, select your jpg. Click on it in Solution Explorer then in the properties box change the Build Type from Content to Embedded Resource.
Now when you want to load it,
Bitmap myJPG = new Bitmap(GetType(), "myPicture.jpg"); assuming that the class is in the same assembly (ie project) as the jpg.
Good Luck,
James
Simplicity Rules!
|
|
|
|
|
Thanks James, sometimes some of the easiest things aren't known by all, I just hope this helps someone else too.
Nick Parker
|
|
|
|
|
I wouldn't classify it as the easiest thing to come up with; it took me about a day of working on my own to figure it out. And then I read it last week in Petzold's book
James
Simplicity Rules!
|
|
|
|