|
Do you have enough permissions to write to event log?
|
|
|
|
|
Hi Giorgi,
Yes, I have full admin permission.
I try the same with .NET EventLog class which was working fine...
Thanks,
Chintan(India)
|
|
|
|
|
Hi,
I have created an entry in a custom event log:
if (!EventLog.SourceExists("TestSource"))
EventLog.CreateEventSource("TestSource", "System");
EventLog evtLog = new EventLog();
evtLog.Source = "TestSource";
evtLog.WriteEntry("This is a test", EventLogEntryType.Information);
I now decide to use my own custom log so I change "System" to "TestLog".
This doesn't do anything. The event is still logged to the "System" log even if I try deleting the source but if I use a different source, it then gets logged correctly to "TestLog"
if (EventLog.SourceExists("TestSource"))
EventLog.DeleteEventSource("TestSource");
If I go into the registry, I find a list of sources for the System event log but even if I delete the TestSource entry from there it still logs events to the System event log.
This MSDN article suggests that you can remove a source association from a log but it's not correct as far as I can tell:
http://msdn.microsoft.com/en-us/library/k57466fc(VS.71).aspx[^]
What's going on? It seems that once a source is associated with a log there's no way of removing that association.
|
|
|
|
|
Restart your machine...Hope it will work.
Thanks,
Chintan(India)
|
|
|
|
|
hello
Anyone done class property/attribute validation in C# (not ASP.NET but simimlar concept) using reflection? I'd avoid writing my own custom validator - anything out-of-the-box to do this?
Thanks
dev
|
|
|
|
|
Are you the only one who knows what's valid?
|
|
|
|
|
i am just hoping the kind of validator available to ASPNET is available for C# (or is it?)
dev
|
|
|
|
|
I don't know enough ASP.net to render an informed opinion.
|
|
|
|
|
devvvy wrote: Anyone done class property/attribute validation
What do you mean? Do you want to validate your business rules? If yes, here[^] is an excellent article on CP.
|
|
|
|
|
hey this is actually what I am looking for.
I was hoping there's something straight from dot-net framework though.
Thanks
dev
|
|
|
|
|
devvvy wrote: I was hoping there's something straight from dot-net framework though.
IDataErrorInfo is provided in .NET framework to create custom error information. That's what the article which I given refers.
Glad to know it helped
|
|
|
|
|
hello
I want derived class to automatically call a particular base class method BEFORE "return" statement, how can I do that?
class SomeDerived : SomeBase <br />
{<br />
...<br />
public SomeDerived() << Constructor called *After* SomeBase's constructor is invoked<br />
{<br />
...<br />
SomeMethod(); << This is what I plan to do, but I don't want burden of invoking this base class method to resides on Derived class (and at same time I can't put this on base class constructor because this must wait till Derived class finishes before invoking)<br />
return;<br />
}<br />
}<br />
<br />
class SomeBase<br />
{<br />
...<br />
SomeMethod();<br />
...<br />
}
Thanks!
dev
|
|
|
|
|
Other than making a factory method to do it, I don't think so. (Of course I could have simply misunderstood you too.)
|
|
|
|
|
You can't make it do it automatically. With MFC, you could use PostMessage, which would then cause the message to be sent when the current method had ended, but I don't believe C# supports anything like that, nor am I sure what would happen if you p/invoked PostMessage.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
You can't do that. But why would you want to do it anyway? It's against OO principles, and the solution you pointed out is perfectly valid. Everything else would make things much more complicated, obfuscated, and error-prone...
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
i wanna get Struct's address.
now i use DLL(made by API), so i have to use Pointer~
ofcourse i already use "unsafe" keyword~
i can get other variable's address..
but...struct's address... i can't...
please help me~~
for example~~
public struct first
{
.......
} //make struct
first fir = new first();
unsafe public void test_1 (first* a)
{
.......................
}
unsafe public void test_2 ()
{
test_1(&fir); <-------------------- This part has problem~
}
|
|
|
|
|
Hi,
you don't need unsafe to use P/Invoke.
What you should do is use the GCHandle class to pin objects (so the GC won't move them around),
then obtain their address, pass that as an IntPtr, and afterwards free the handle.
You don't need to do this for strings though: a read-only string can be passed as is, and your C code will get a valid char*. For a writable string, use a StringBuilder instead.
Make sure you describe the structs correctly; be careful with the size of simple types,
long in C# is 64-bit, in most C environments it is 32-bit; and char in C# is 16-bit, in C it is 8-bit. Also be careful with alignment, the byte stuffing rules could be different on both sides.
|
|
|
|
|
|
hi every body
how can i write a program in C# and run it in another pc that, THAT PC hasn't installed .net ?
i don't want to install .net in that pc, I mean how can I embed it in my program?
if evry one knows this....
saeed_saeed7007@yahoo.com
or
7007.saeed@gmail.com
|
|
|
|
|
As far as I know, you have to have the .net framework installed if you're program utilizes the .net framework or Mono[^]
|
|
|
|
|
|
|
I am using Visual Studio and I am trying to update my datagrid using the info from text boxes rather than using the binding navigator to directly input the information. I was hoping that I can fill in the fields with the info and click a button to update my datagrid. Is this possible? If so how?
|
|
|
|
|
The easier way is using a dataset n update it.
Good Luck.
|
|
|
|
|
I am trying to figure out how to throttle the bandwidth used by my socket. I am having trouble figuring out how to break up the send buffer into smaller pieces and still let the receiving socket know that all the pieces are part of a single send.
|
|
|
|