|
You don't.
If the class inherits IDisposable, e.g. has a Dispose method, you call that method to clean up any unmanaged resources. Then you get rid of the reference to the object, and it will be garbage collected eventually.
You can invoke a garbage collection manually, but there is very rarely any reason to do so. If the system or the .NET heap needs more memory, a garbage collection will occur to try to free up memory.
---
b { font-weight: normal; }
|
|
|
|
|
I have a lot of C++ resource files that I need to include but I have to do so in C#. Any thoughts?
Ericson
|
|
|
|
|
Hi
I am making a project of chess game for which i have to import gif images of chess pieces .can anyone tell me how to put images in windows forms. do keep in mind that i am making the chess board using GDI+. and do tell me how to move/redraw that image. help in this regard would be appreciated.
|
|
|
|
|
Salam,
Dear u have to deal with 2 methods of GDI+.
1. Graphics.DrawImage();
2. Graphics.FillRectangle();
When u move one piece from one black box to other simply draw the moved piece on the new box using Graphics.DrawImage(); and fill the older box with the black filled rectangle using Graphics.FillRectangle() Method. and so on.
First of all u have to divige the whole Form or panel into the boxes then the above mentioned proceedure will be applicable. If u want further info. Please write more. And also Consult MSDN for these methods.
Cheers,
Rizwan
|
|
|
|
|
What dotnetdev83 told will work. Another clever way of doing this create dynamic buttons on your form, assign a GIF image to its Image property, and then write code to drag it around.
Though totally unrelated to chess, this[^] article's code shows you how to do it. Plus point of this method as they are "button"s you can handle the click event and other events easily.
Koushik Biswas
|
|
|
|
|
I posted this once before, but it is about 20 pages back now. I am using EM_SETCHARFORMAT to try and set the background color of charachters in a RichTextBox, but it wont work. I have tried everything I can think of, and nothing. When I try and set the forecolor, that works, and I can paste in charachters with a set backcolor and it works fine, the code just isnt working how I want it to...
I tried dwEffects=0, dwEffects=CFE_PROTECTED, not setting dwEffects, etc. Nothing has worked. The call to DefWndProc is returning a non zero value, so it is working, just not how I want it to. There has to be something I am missing somewhere... I am going to list all my constants, structure, etc, and perhaps someone can figure out what is going on. FYI, I have also tried the API call and it does the same thing.
[StructLayout(LayoutKind.Sequential)]
private struct CHARFORMAT2
{
public int cbSize;
public int dwMask;
public int dwEffects;
public int yHeight;
public int yOffset;
public int crTextColor;
public byte bCharSet;
public byte bPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string szFaceName;
public int wWeight;
public int sSpacing;
public int crBackColor;
public int lcid;
public int dwReserved;
public int sStyle;
public int wKerning;
public byte bUnderlineType;
public byte bAnimation;
public byte bRevAuthor;
public byte bReserved1;
}//struct charformat2
//constants
EM_SETCHARFORMAT=0x444;
CFM_BACKCOLOR=0x4000000;
CFM_COLOR=0x40000000;
SCF_SELECTION=0x1;
//Call to format, tried CFM_BACKCOLOR and CFM_BACKCOLOR|CFM_COLOR, etc,
// only forecolor changes
CHARFORMAT2 cf2=new CHARFORMAT2();
cf2.dwMask=CFM_BACKCOLOR;
cf2.cbSize=Marshal.SizeOf(cf2);
cf2.crBackColor=ColorTranslator.ToWin32(Color.Red);
IntPtr lParam=Marshal.AllocCoTaskMem(Marshal.SizeOf(cf2));
Marshal.StructureToPtr(cf2, lParam, false);
Message msg=Message.Create(this.Handle, EM_SETCHARFORMAT, (IntPtr)SCF_SELECTION, lParam);
DefWndProc(ref msg);
Marshal.FreeCoTaskMem(lParam);
|
|
|
|
|
Hi again!
Now I've tried your code and found that your struct definition is not correct.
For example, wWeight and sSpacing are not int (32 bit), but UInt16 (16 bit). Same with sStyle and wKerning.
Because your struct declaration is wrong, the bytes are shifted and thus do not work.
Regards,
mav
|
|
|
|
|
Thanks. All I had to go by was the struct definition on MSDN's website, and it was for c++. I wasnt sure exactly what the exact conversions were for each of the elements, but I knew it had to be something like that. It definately makes sense though. I appreciate your help! Thanks!
|
|
|
|
|
I am experiencing a problem with integrating a help function (created with HTML Help Workshop) inside my splitcontainer.
Does anyone know if this is possible?
I have researched the issue and only found possibilities to display popup help or help in a separate window.
Freya
|
|
|
|
|
Hi everybody!
Can anybody tell me if it is possible to build an executable, form a C# code made in Visual Studio .net 2003, that not requires framework installed?
Thank you so much
|
|
|
|
|
Not in a very practically way. There are tools which compile c#-code in win32-exe files but they are very expensive.
With the build in tools from vs.net it is not possible.
'A programmer is just a tool which converts caffeine into code'
|
|
|
|
|
Actually, if you use XenoCode and ask it to embed the .NET framework, it will embed it in to your applciation codebase (binaries), so you don;t have to ask your customers to have .NET Framwork installed.
|
|
|
|
|
How could this possibly work? Embedding the JIT IL runtime in a binary is one thing. Embedding the whole of the .Net Framework (there is a reason why its a multiple MB install, there is a lot of stuff in it) is something different.
In any event, yes there are tools out there that try to sidestep the .Net Framework through runtime tricks but in general you have to ask yourself why do you want to this? Maybe C# isn't the best tool for your problem since you can't/don't/whatever use the .Net Framework.
|
|
|
|
|
Odd, nowhere in their documentation do I find that this elimanates the need to have the .NET Framework installed. All I found was:
NET Framework embedding: Xenocode Postbuild 2006 allows the .NET Framework libraries to be embedded into the output assembly, dramatically reducing the complexity of application testing, deployment, and support. Xenocode Postbuild 2006 automatically identifies and statically binds a minimal set of Framework dependencies, reducing overall deployment size and eliminating dynamic link costs.
OK... say this is true and you really do get the minimal .NET Framework statically linked into your app, so you don't need to have the .NET Framework installed. Now, write and deploy 10 apps using this method to your entire user base. Now you've got, at a dead minimum, 10 copies of mscorlib linked into your applications. Lots of duplicated code and wasted space. Whoops! SP1 for the .NET Framework comes out and it fixes nagging problems you've had in a few or your apps. Recompile, relink, and redeploy your busted apps.
Now, go back to square one and start this experiment over. Deploy the .NET Framework to all of your user base. Now deploy all of your apps (much smaller since they don't include the Framework statically linked into them and just as easy to deploy). Now SP1 comes out for the .NET Framework. All you do is deploy the SP to your user base. Don't have to recompile any of your apps because dynamic linking takes care of using the updated Framework classes for you.
I can live without static linking the .NET Framework into my apps.
This is just from a LAN Admin's point of view. If I only have to deploy the SP to fix these problems, GREAT! More time to do other things.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Why do you use a .NET programming language if you want to run it outside .NET? It's a totally imbecilic demand!
Regards,
Nish
|
|
|
|
|
I started programmin in november 2005.
I've choosen .net platform, but someone asked me for an executable running without framework and I tried to get informations.
Now I'm watching at C++...but your answer is offensive, not all people are expert like you!!!
We are on a forum, so a minimal respect is necessary.
Sorry for my bad english
|
|
|
|
|
hellamasta wrote: Now I'm watching at C++...but your answer is offensive, not all people are expert like you!!!
We are on a forum, so a minimal respect is necessary.
I am sorry if I offended you, but my reply was to a more general audience. Every week, we get questions from people where they want to deploy a managed .NET application on a machine that does not have the .NET framework on it. It clearly indicates that they have begun coding on .NET without getting even a basic understanding of the framework. It's frustrating to think that people would do that. It's like buying a car and beginning to drive on a busy road without understanding the basic traffic rules.
And note, I am no expert, just a guy who codes for a living.
Regards,
Nish
|
|
|
|
|
I've encountered an error in XML serialization, and was wondering whether any one else had seen the same error (MVS 2003 + .NET 1.1).
The error is: "The was an error reflecting type Example.XMLSerializationError", and occurs when I execute the following code
XmlSerializer xmlSerializer = new XmlSerializer(new XMLSerializationError().GetType());
And the error is caused by the public get property troubleMaker (below), which the serialization should ignore since there is no set method on the property! Uncomment the [XmlIgnore] attribute and no error occurs!
using System;<br />
using System.Collections;<br />
using System.Xml.Serialization;<br />
<br />
namespace Example {<br />
[XmlRoot()]<br />
public class XMLSerializationError {<br />
public XMLSerializationError() {}<br />
<br />
public int harmlessMember_;<br />
private Queue troubleMaker_;<br />
<br />
public Queue troubleMaker {<br />
get {<br />
return troubleMaker_;<br />
}<br />
}<br />
<br />
<br />
}<br />
}
|
|
|
|
|
You need a get/set methods on properties for proper serializations. You get the reflection error because of the absence of the "set" method.
With XmlIgnore, the serialization simply ignores the property, hence you get no error.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Hi Michel,
Thank for the suggestion. But sadly you're mistaken.
Adding a set method isn't necesarry (XML reflection code should ignore the property), but even if I add the set method, the error still occurs.
Jesper
|
|
|
|
|
Jesper1966 wrote: But sadly you're mistaken
Unfortunatelay, I am human.
But I am a little surprised. I suggest, as you are already on the path to knowledge, to pursue on this avenue and keep me informed.
Thanks,
Michel
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Hi Friends,
I have used DataGrid in my application. My client requirement is the field change is written to the database as soon as the user navigates away from the field. Please suggest me how to do it.
Regards,
Prakash.
A Journey of thousand miles must begin with a single step.
|
|
|
|
|
Firstly, how are you databinding the data to the datagrid. Secondly, when you say "written to the database", do you mean a local or remote database?
|
|
|
|
|
Hi,
Did you mean how can i associate the data to my Grid ?
I have use thed following code to specify the datasource for my GridControl
DataView curView = ScheduleDataSet.Tables[ScheduleTableName].DefaultView;
curView.AllowEdit = true;
curView.AllowNew = false;
curView.AllowDelete = true;
dataGrid1.DataSource = curView;
So whenever the user modifies the data in the edit field, we have to reflect the changes in assoicated Dataset and the corresponding database also(in this case we have used the database as mysql).
Regards,
Prakash.
A Journey of thousand miles must begin with a single step.
|
|
|
|
|
This is the message I keep getting more often the last few weeks..
And I only get it with my .Net Applications ...
The real question is why ?
I've reinstalled my .Net Framework ( 1.1 and 2.0 )
And the error still persisted
I reinstalled windows ( didn't format it ) and I still got it...
Finally I deleted the files and recompiled everything ? It worked... but the debug still gives that error ... Have to mention that this is the first time I ever received the error...
Do you know of any viruses that could cause something like this ? ???
I have a backup of my program ( the one I'm working for about 4 months .. and it's verry big ) Didn't get the message here... so I'm hoping it's a virus that I have at home /??
Does anyone know of any reason for why the message appears when I execute a program written in DotNET ?
Lazar Mihai
Highschool student
|
|
|
|