|
Example of what? I have no idea what your code is doing or how you are managing your data. Just think about what you are trying to do. If you change the definition of a class after it is serialised, then the data will no longer match. So you need some way to use the previous definition to deserialise it. How you achieve this will depend a lot on the structure of your data and the associated classes.
|
|
|
|
|
Yes, but i have no idea to achieve it...Could u help me?
For example,
Class A
{
int a=0;
int b=0;
}
When i finished serialise class A and create a local file "Saved".
When i update my Class A
Class A
{
int a=0;
int b=0;
int c=0;
}
Then deserialise "Saved", it will throw exception ,how can i do it? I hope when i deserialize "Saved",it will ignore c.
|
|
|
|
|
You cannot do it with the new class, because it does not match. You must deserialize into an instance of the old class and then copy the data to the new one.
[edit]
If the new version of your class is actually based on the original you may be able to do it that way using a cast. Should be easy to test.
[/edit]
|
|
|
|
|
Oh, actually, my Class is a form , i use serilized to store input data, like textbox or radiobutton data.
When my project version update, maybe i will add some textbox or other controls in form class, so i will not deserilize old file, i don't know how to handle it.
Please tell me a method to realize save function.
|
|
|
|
|
You probably need to write a custom serialiser.
|
|
|
|
|
Please help i am new to C# and i have a windows form with textbox1, textbox2, and buttom1 i would like to print the value of textbox1 without previewing or let me say straight to the printer without any interactions, textbox value has to be the number of capies i would love to print and also to page number all those copies say if i input 3 it should say page 1/3 2/3 3/3 please help and excuse my english i have the following code under my button
private void button1_Click(object sender, EventArgs e)
{
PrintDocument printDocument = new PrintDocument();
printDocument.DefaultPageSettings.Landscape = true;
printDocument.DefaultPageSettings.PaperSize = new PaperSize("zed", 400, 850 );
//printDocument.PrinterSettings.Copies = 2;
printDocument.PrintPage += PrintDocumentOnPrintPage;
printDocument.Print();
|
|
|
|
|
Hello all,
I have a (personal) screensaver that shows particular content based on what applications are running. Under Win10 the program runs perfectly when executed directly (ie. running the exe), however when the program is executed from Windows10 (via screensaver trigger) the application can no longer enumerate Process windows.
Specifically:
If i use the following code snippet:
using System.Diagnostics;
Process[] processlist = Process.GetProcesses();
foreach (Process process in processlist)
{
if (!String.IsNullOrEmpty(process.MainWindowTitle))
{
Console.WriteLine("Process: {0} ID: {1} Window title: {2}", process.ProcessName, process.Id, process.MainWindowTitle);
}
}
and run the application I get a proper list of open windows. But if the SAME application is launched as a screensaver, the above code produces nothing. Never had this issue under Win7 or previous.
Does anyone have any idea what might be happening ?
Thanks in advance,
Andy
|
|
|
|
|
Disclaimer; I never touched Win10 - but it may just be running as another user. Something like the SYSTEM account, with limited rights.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks for the reply. I checked and SYSTEM has full admin privledges. I even changed and made sure that the app had FULL access as either myself or SYSTEM. Same effect.
(It's hard doing a google search on this because you get a zillion hits for "how to change your screensaver" LOL)
Still stuck ...
Andy
|
|
|
|
|
Your only recourse is to add debug/logging code to the screensaver to find out what is going on when it runs for real.
|
|
|
|
|
andymo2 wrote: I checked and SYSTEM has full admin privledges. Great. Format your box, or throw it away - SYSTEM is a limited account for a reason.
Another scenario where this would fail would be if the screensaver (or the OS) opens a new desktop. You may not have enumerate-priviliges there, and it may not have any open windows.
Is there error-logging included in the code? Iow, are you sure there is no exception thrown that terminates the execution of the screensaver?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
As Eddy said, I think your screensaver is running in a different desktop:
By default, there are three desktops in the interactive window station: Default, ScreenSaver, and Winlogon.
...
Whenever a secure screen saver activates, the system automatically switches to the ScreenSaver desktop, which protects the processes on the default desktop from unauthorized users.
According to a comment on this 2006 blog post from Raymond Chen[^], if you tick the "on resume display log-on screen" option, your screensaver will be run in "secure" mode.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for all the responses.
I don't have "on resume display log-on screen" checked. However it seems like it might be something like a separate desktop (I never knew!)
.
I re-coded the screensaver so that when it runs it only fills half of the screen. The idea was so I can get a look at the task manager and see what user/owner the program was running under (because I can't usually see it when it is running obviously).
Some observations:
- the screensaver runs correctly when activated by the "preview" button in the screen saver management dialog. It gets the enumeration of windows, and it only fills half the screen and I can read the task manager.
- when triggered by the OS after being idle, the program correctly only fills half of the screen but the rest is black and the rest of the desktop is gone.
So how can I get this desktop to be able to see what programs are running ? It is able to read from the HDD and other parts of screensaver that work.
This has worked for years on Windows 7 and 8, and I am only an intermediate C# coder. Frustrating.
|
|
|
|
|
andymo2 wrote: he screensaver runs correctly when activated by the "preview" button in the screen saver management dialog.
That's because when the screen saver is launched from that dialog, it's running as YOU, not the system.
andymo2 wrote: when triggered by the OS after being idle, the program correctly only fills half of the screen but the rest is black and the rest of the desktop is gone.
That would be because you're looking as the secured desktop screen savers run under.
andymo2 wrote: So how can I get this desktop to be able to see what programs are running
You don't. That desktop hjas been secured to the point where anything running under it cannot see the processes running under a different desktop, namely the users desktop logged into the console.
andymo2 wrote: It is able to read from the HDD and other parts of screensaver that work.
Yes, a screen saver running on the screen saver desktop still has access to other system resources, such as the local drives.
|
|
|
|
|
|
Why even bother with a "screen saver"?
Any program running "full-screen" (or not) will meet your requirements (based on your description).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Gerry, you might have a good point there. The program is sort of our family dashboard that runs on the kitchen computer. The idea being when someone is not using the computer it will show the family calendar (which we live off of), the weather, random photos, and if the music player is playing it will show the current playing album (hence connecting to another program).
I guess I could just write my own small launcher program that will launch the dashboard based on win32.GetIdleTime instead of relying on Windoze screensaver.
Thanks for the brain-jog!
|
|
|
|
|
Yes!
Program can run in the background and task bar on startup. I've used keyboard and mouse hooks to monitor activity.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Threw it together. Working great. Thanks everyone for all the help (and the knowledge!)
Andy
|
|
|
|
|
Hi all, suppose I've queried a data source and let's say 10 thousand records are supposed to come back. If I want to pause the reception of the data at a particular record and then resume the data reception on button click is there a way to do this using C#? Thanks in advance.
|
|
|
|
|
Unless you're using a DataReader, no there isn't.
Unless you doing processing on all those records, returning 10,000 records to display them is just stupid. Use paging instead so you're not sitting around waiting for that many records to load and be bound to a visual control.
|
|
|
|
|
Besides "paging", the other keyword here is "virtualization" (often used in the context of list and grid controls)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I have this windows service application installed on my windows server.
It's job is to check a specific table from sql database every 5 minutes and send me a notification via email when the table has new records inserted on it. My windows service is set to start automatically however, when the server is restarted, the service wont run until I logged in.
Long story short, what i want is to start my windows service automatically even if i don't login.
I want it to run when my windows server is on logon screen after restart.
Thanks to anyone who can help me.. I really need this and tried to google for a day and no luck for me.
|
|
|
|
|
I think you need to set it up to run under the Windows account rather than your own.
|
|
|
|
|
Thanks for this. Tried to set up with Network Service account and works like a charm.
|
|
|
|