|
I have a small printing application (using PrintDocument class).
I have several Printer Drivers installed on my comp, but when I physically disconnect any printer and try to Print anything, the application abruptly terminates.
Can any one guide please?
|
|
|
|
|
Use proper error handling mechanisum (try...catch) to identify the error type and source.
And check whether your printing logic will take any default printer or networke printer to print the required page.;)
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Need an example on Session Ending.
|
|
|
|
|
If you ask politely, someone might actually answer.
mav
|
|
|
|
|
|
I have a problem with registering my software, but i don't know how to security my trial version. Can everybody help me?
Đào Ngọc Hào! Hi How Are You?
|
|
|
|
|
Little confused.
If you want to run your application as a Trail version , then you need to add some logic in your source itself to check the license or validity.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Hi Thank you for your answer!
But just more somethings I don't understand. If someone decompile my main application and view the directory where contains registry information. Then That's it. Is there any solution for this.
Đào Ngọc Hào! Hi How Are You?
|
|
|
|
|
You might try storing an encrypted date (or some other data to identify your program as a trial version) in the Windows registry. But don't put it in an obvious place and call it by an obvious name. This way it is not as easy to beat. Be careful in the Windows registry, because you could mess up a program (even Windows itself) and have to reinstall the program.
If you don't know anything about encryption, try searching for it here. There are several ideas about encryption out there that will help you.
|
|
|
|
|
I have a student class with attributes: name, id,... And I want to save it to a file then restore it. I don't know how to do that. Please help me.Thanks
|
|
|
|
|
|
First you need to mark your class with the [Serializable] attribute so the fields/properties can be mapped to your output file.
To write the file youve got a few options. First, you can use an XmlSerializer and TextWriter to write the file as XML formatted text. You can write the file as as Binary file using the FileStream and BinaryFormatter classes.
|
|
|
|
|
Hello , i am MCSD.NET but i don't know how send Article in to the Code Project help me to How do it
|
|
|
|
|
|
1) can someone help me with code for reloading a form after a button event.
2) also looking for code for running a second form after a button event ie. application contains 2 forms and i'd like to view the second form.
thnx
|
|
|
|
|
1) You can reload the form while calling the Show() method of the form.
Eg:
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
this.Show();<br />
}
2) If you want to show another form from the active form, then you can create the instance of second form and use the Show() method.
Eg:
private void button2_Click(object sender, System.EventArgs e)<br />
{<br />
Form2 frm=new Form2();<br />
frm.Show();<br />
}
Here what you need to notice is, your application will always create new instances of Form2 for each button click.
To avoid this, you can add a Form2 Type declaration and can use this member to create instance of the type Form2 . So now your application show the second form once for every button click.
Eg:
private Form2 frm;<br />
private void button2_Click(object sender, System.EventArgs e)<br />
{<br />
if(frm!=null)<br />
frm.Show();<br />
else<br />
{<br />
frm=new Form2();<br />
frm.Show();<br />
}<br />
}
Sreejith Nair
[ My Articles ]
|
|
|
|
|
I have a webpage with links to xml files. Once a day I have to download these files and store them on a harddisk. I do this by clicking the link and choosing [Save] and so on. I would like to make a component in C# which reacts when the specific URL is called, runs through the html and retreives all files.
Is this possible and how do I register the component to react when the specific URL is called in IE.
|
|
|
|
|
There are many questions before answering this, do the URL's change that point to the XML files? Why does it have to deal specifically with IE? You could request the HTML everyday, parse the returning document for links to XML files and request each XML file.
|
|
|
|
|
Thank you for the quick response.
I will try and explain the problem a little better
The links are at a remote site where I use a chipcard validation to enter. This validation is only valid for this session and the site can only be accesssed by IE and I have no control over this site. So what I am trying to do is making a component which simulate me clicking at the links (up to 800 files) and choosing save when I enter this page.
|
|
|
|
|
You could still perform the individual requests once you were logged in. Also, you could make it appear as if you are coming from IE if the site you are logging into is checking the headers that were posted. Check out the HttpWebRequest[^] class to see if that gets you started.
|
|
|
|
|
I created a new custom control, based on the ComboBox standard control, by inheriting the control. I then put it into a library and added the new control/tool to the toolbox.
After adding the control to a program in several places, it seemed to work as desired and the compiler had no problems with it. However, about 1 out of 10 times, when I go display the interface layout in the visual designer, Visual Studio strips out ALL initialization code for all of the custom controls. It is becoming a major headache having to go and compare the version with the last checked into sourcesafe and try to reconstruct the control initialization code.
Is there any way to get Visual Studio to STOP STRIPPING OUT ALL INITIALIZATION CODE ON CUSTOM CONTROLS????!!!!!!
I am NOT doing anything strange with the control (i.e. adding special code in the InitControls() or anywhere else that Visual Studio has set aside as dynamically generated by a designer refresh). It just insists on stripping out the code IT added when I added the control!!!!
I am having to re-add this init code about 3 or 4 times a week and it is getting EXTREMELY AGGRAVATING!!!!!!!
|
|
|
|
|
|
Thanks for the help. Much of that can help. However, my problem is actually a bit more severe. The following has been true every time I got hit by it...
1. it never happens when starting VS or opening a project. In fact, I will have recompiled successfully/cleanly many times over several hours and it runs fine. I look at the designer window and all looks fine.
2. simply switch between code view to designer and all is ok.
3. make a change on designer view, then switch from designer view to code view and [on occasion] there is a massive pause, then it won't compile. Go back to designer [no pause] and the custom controls are gone. It has always happened when I switch from design view to code view.
4. it has occasionally happened DURING saving changes. After making changes to the designer, I would quick scan around the form to make sure all is ok, then click save. There is a massive pause while designer scans, then the custom controls vanish and it saves the updated file without the custom controls.
5. it has ALWAYS ONLY happened on those custom controls. It has NEVER happened with other controls.
|
|
|
|
|
I'm pretty sure this is "The Woe" described in the article. I know what you're experiencing because when I was using VS 2k3 I experienced it first hand, and only when dealing with custom controls.
The trick, as I remember, was that, before opening ANY designer, rebuild your custom control and make sure everything is saved. If the designer wipes out all your controls, just exit the designer without saving. You're safe, you code is preserved.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Lies of Our Fathers: A Must-Know About Lent
Judah Himango
|
|
|
|
|
Oh yeah. Don't get me wrong! I believe it to be the same as well. I am only saying that I believe I have encountered many more causes of the problem, and since I have not been hit by any of the causes indicated in the article, that most of the tips in the article probably won't be of help. I have implemented the following process to see if it helps in my case...
1. place the code for all custom controls in separate library projects. Then add the required control projects as sub projects to the main project that needs the control. Make the main project compile dependant on its compile. Then when I open the main project, compile it before starting any work. In fact, I have gotten in the habit of compiling several times to make sure everything actually gets compiled and refreshed properly.
2. create new custom controls, in the project, that inherits each specific instance of each customized custom control and copy the parent's initialization code into it. For example, if 'a' is a custom control, then create a new object 'b' based on 'a', and create an 'Init()' method in 'b', called from all constructors of 'b'. Then, copy the initialization code of 'a' to the 'Init()' method of 'b'. Then, in the main form load method after the InitializeComponent(), check to see if the auto generated reference to 'a' is null. If so, then declare an instance of 'b' and assign it to the reference. At some point, I should then go back and remove any stray left-over auto-gen code referring to 'a', and then re-add 'a' from the toolbox and then replace the initialization code of 'a' with that in 'b'. This will allow me to start visually editing it again... at least for a while. The down side to this is that if I make visual changes to 'a', I will have to remember to update the init code in 'b' with the changes. This is cumbersome, but considerably less so than having to completely re-add all missing controls from scratch!
3. whenever making a change to the visual layout, switch to the code view before saving. If I make changes to the code, switch to the design window before saving. This way, if the problem hits, it will hit BEFORE the save rather than during the save. It will take some time to make this habit, but it should ensure that the problem does not strike during the save or compile, but rather during the window swap. If controls disappear after swaping, simply close the window(s), choose not to save, and then re-open them. Is there a way to turn off auto save? To make this step reliable, I will have to make sure I know when the save is executed. Also, is there a way to have it create a backup of the current source before saving? I have not been able to find these anywhere, but being able to configure these (if possible) would help tremendously.
|
|
|
|