|
Using 0 for your default value is quite dangerous (0 is often a valid input). If you're using a floating point type, NaN is quite good for 'missing data', and this should be what you use in your data model. For integer types you can either specify a special value or use int? and use null for missing. You can then use the CellFormatting tip to show a blank cell when the actual value matches your designated 'null' value.
|
|
|
|
|
Thanks. I've just developed an abhorrence over the years of seeing a whole lot of 0s on the screen when all it means is that the user hasn't filled the data in yet.
|
|
|
|
|
Greetings Gurus,
Come across a problem I don't seem able to solve and was hoping someone could point me in the right direction.
I am building a Windows service which records Event log entries in a sql db. Running it as a console application works fine but when I try and move the code into a service structure I get errors.
My code
public partial class GetInfo : ServiceBase
{
public ServiceName()
{
InitializeComponent();
}
static AutoResetEvent appsignal, syssignal, secsignal;
public static void Main()
{
What should I use in place of "public static void Main"?
I would like to keep this out of the "Onstart" region because I want it to initialise before the service's timer.
Can you help?
|
|
|
|
|
|
Hi again André,
The actual service works (it pulls 2 other sets of metrics of the machine as well). The problem is that the event log watcher doesn't log events to the sql db. No errors, builds fine, works as a console app but just wont log the event log entries.
The link you sent was one that I had used when initially building the base service but thanks for the assist anyway
|
|
|
|
|
It can be failing silently in your code and thus wouldn't log the errors to your DB. You need to add logging to a file (for debugging I mean, not for your real production code) or something more "bullet proof" then a DB. Just off the top of my head, I'd guess its a permissions issue coming from the service.
|
|
|
|
|
Hi Sledge,
I have "try/catch" and the beginning and end of each eventlogwatcher segment as well as console.writelines. No errors are caught by "try/catch" but also there is no printout from the console.writeline.
Its not permissions because all the code surrounding the eventlog watcher runs and reports perfectly.
Its just this one segment that seems to do nothing while everything around performs as expected.
|
|
|
|
|
hello guys.. I have a struct in class A. In one of its function, I returned this struct. I tried something like this (all the getters and setters are there properly)
class A
{
struct MyStruct
{};
public MyStruct func()
{
MyStruct struc = new MyStruct();
return struc;
}
}
class B
{
struct MyStruct
{};
A = new A();
MyStruct result = new MyStruct();
result = A.func();
}
But I get the error
Cannot implicitly convert type 'A.MyStruct' to 'B.MyStruct'. Whats wrong with it? thnx
|
|
|
|
|
You have defined MyStruct in both class A and class B. That means that the compiler will see them as different even if their internal structure is the same.
Define MyStruct outside of the class boundaries only once and your issue will go away.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
thnx..it solved my problem. But let me tell you that I did following
A.MyStruct result = new A.MyStruct();
Is it OK to do so?
|
|
|
|
|
Absolutely, it can be done that way as well.
My personal thought on the matter is that unless A.MyStruct is required to be tightly coupled to class A, it should stand on it's own outside of the class, but like I said earlier, what you have done is perfectly valid.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
class A and class B both have nested structs named MyStruct defined. In class B you have MyStruct result = new MyStruct(); If you intend to use A.MyStruct objects in class B then you need to be explicit:
A.MyStruct result = new A.MyStruct();
Mark Salsbery
|
|
|
|
|
thnx...just after I found it out, I read your suggestion.
|
|
|
|
|
overloaded Name wrote: A = new A();
MyStruct result = new MyStruct();
result = A.func();
You don't need to new up the MyStruct here because it is just getting overwritten by the return. If you were passing in a reference, that would be different, but in the case, you are not.
|
|
|
|
|
Hi all!
At first sorry for my poor write english!
I'm creating a web service for connect a future mobile application and at this moment of the development found a problem. The web service recibe at first a username and password, verify if exists in de DB and return one encripted token, the idea is use this token in the next calls to the diferent functions of the webservice, and in a second function verify if the token send by the client is the same that the web service generate.
Whats is the best way of save this tokens in the service? in a DB? in Sessions? the service can recibe direfent calls by diferent users and generate many diferent tokens in a little space of time.
Hope I explain correctly and can undesrtand my question.
Thanks all!
|
|
|
|
|
Sounds like a session key to me, or something that should be stored in the session along with a key. If your web service infrastructure already has the concept of a session (I can't remember if WCF does or not), put it in there, for sure.
|
|
|
|
|
I put it in the database. One benefit is that if the user logs in from another station later, the new token overrides the old one so the previous login becomes invalid -- avoiding having the user logged in twice.
|
|
|
|
|
Thanks all.
Finally I'm trying to implement the session method but have a problem. I create a little form in ASP.NET to test de WS, 2 textbox to insert the user and password and 2 buttons, one to verify the user and password and a second one to call a WS function that check the if the token sended by the user is the same than the saved in Session but in this function the session value is null.
When I call the second function this call again all web service and this empty all the data?
If you need for understant better my queston I can post the WS code.
|
|
|
|
|
Just wondering if anyone else has experienced this before. I have a check box with style Appearance:Button (actually it is wrapped in a user control but that isn't relevant here). Two instances of this check box on different panels within the same application are displaying differently: one has the normal 1px control border like real buttons, and on another panel the same control is displaying with a double thickness border. It also seems to be offset by 1px when I try to read its location, or alternatively its painting region is offset by 1px (I'm aligning another control on it and it is not quite lining up).
|
|
|
|
|
How do I put my window at the top of your desktop (by analogy - the task bar)?
|
|
|
|
|
What do you mean exactly? TopMost or on a certain Location?
Are we talking WinForms or WPF?
V.
|
|
|
|
|
You are not going to put any of your windows on my desktop, you hear!
It is strictly forbidden!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
|
|
Fetch[^] handle of the desktop-window, set it as your parent[^], make your form the "bottom most[^]" and you're there. Should look like an IFrame in your desktop, should work and behave in the same way.
Good luck
Bastard Programmer from Hell
|
|
|
|