|
Hi All,
I've created a common sub procedure that can log the service status into Custom EventLog.
'********************************************************************<br />
' Process: ServiceLog<br />
' Input: LogSource, strLog, strType, EventID, Category<br />
' Output: Write into EventLog<br />
'********************************************************************<br />
Public Sub ServiceLog(ByVal logSource As String, ByVal strLog As String, ByVal strType As EventLogEntryType, ByVal EventID As Integer, ByVal category As Short)<br />
Dim logName As String = "My_Services Log"<br />
If Not EventLog.SourceExists(logSource) Then<br />
EventLog.CreateEventSource(logSource, logName)<br />
End If<br />
<br />
Dim MyLogAs New EventLog()<br />
MyLog.Log = logName<br />
MyLog.Source = logSource<br />
MyLog.WriteEntry(logSource, strLog, strType, EventID, category)<br />
End Sub<br />
My service was installed and run without error. When i check the EventLog, supposing that it should write into the my Custom Log["My_Service Log"],
but it wrote into the Application Log.
Any idea how to solve this?
Thanks...
Regards,
Sayhigh Soon, Junior Programmer
|
|
|
|
|
I believe that the Microsoft documentation is very misleading in this respect, or the 'custom log' was a direction in which they never headed.
I too wanted to create a 'custom event log' many years back, and was not EVER able to find a way in which to do it - I REALLY tried everything I could think of and wrote numerous test applications against the published API. I became convinced there are only THREE event logs EVER - Application, Security, and System.
Your best option is to effectively utilize writes to one of the existing three logs and to thoughtfully choose your SOURCE and CATEGORY, since you can easily sort the event log based upon these fields.
|
|
|
|
|
I do tried to edit the registry before..
i did it..but i'm not sure what is the steps to archieve that.
what i want to archieve is install windows services with the eventlog features without modifying the windows registry.
Anyway..thanks for ur valuable info..
|
|
|
|
|
I do this in VC++.
To create a new log file you create an entry in the registry. The log event service will see this and create the appropriate log file and entry in the event log manager. The one thing to watch for is the difference between the display and file names. If you want them to be different then you will have a race with the event log service. As soon as you create the display name entry you are racing to add the 'File' subkey entry before the event log service reads the change and creates the file based on the specified display name key. If you get there first then the service will use the specified 'File' key to create the file.
So, in the registry under HKEY_LOCAL_MACHINE create :
SYSTEM\CurrentControlSet\Services\EventLog\<display name="">
Then right away set the following keys :
REG_EXPAND_SZ File = %SystemRoot%\system32\config\<file name="">.evt
REG_DWORD MaxSize = 0x00080000 (524288)
REG_DWORD Retention = 0x00000000 (0)
Next you have to create and register a source ... after that everything should work.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I'm a budding programmer looking for vital threads. Learning language and using it are 2 different things although one MUST receive it before they can express it. Grasping the basic concepts of OOD and the languages (VB,C#,C++(concepts)), learning the system classes, .net and language functional constructs (gdi,reflection,diagnostics), etc. etc. , What is(are), the single best tools to use to convert ideas into code?
1. UML??
2. Keep reading??
3. Keep doing??
4. Usage of interfaces, events(delegates)??
5. A pad and a pencil??
Any thoughts to help steer me into coding effective design, architecture, OUTPUT!!! .....TIPS .. pLeAsE
Trane Lives (that's Coltrane)
THANX
ds
|
|
|
|
|
I advise you to read Refactoring by Martin Fowler. Uml and other things may be good. But I believe in iterative development. If you need something first build it however naive it can be. Then add to it, refactor it. I never build my inheritance classes at outset. I first build something, when I start to copy paste. I look for common parts to use in inheritance. Refactoring books teaches you how to this. Of course this is my opinion.
Education is no substitute for intelligence. That elusive quality is defined only in part by puzzle-solving ability. It is in the creation of new puzzles reflecting what your senses report that you round out the definition. Frank Herbert
|
|
|
|
|
But doing it this way, building it first; That's what I do now. You're saying, wing it from your knowledge, base, research, etc. tied with your coding logic...putting it together and then Refactor it. How do you take a heavy architecture, that you've now created (the mistakes of design you've now issued, not having the complete answer until you've reached the end) and re-make it into something light and elegant??
Does Refactoring allow you to pull out those 'guts', allowing redesign, without upsetting the wheel that pulls the applecart...(Breaking something that's not broken, just a little slow)
ds
|
|
|
|
|
Lets say this. You will learn while you are coding and designing. Your mistakes will teach you. For example I am in a project now. Which uses web services from a third party. This third party publishes web services which have same interface but they have diffrent names. I have tried to implement this using interfaces in my code. It worked but it was ugly and hard to change. I changed my code to use one abstract class and factory pattern. Now it is very easy to extend my design to accommadate other web services from this third party.
But first I have implemented one solution. Then I looked my solution and changed it. I have not arhictected last solution first. Of course you need some knowledge for this.
Of course you never have complete answer. If you do not need to expand that application leave it as it is. It is working. But you have to maintain and extend it. Then As I have done, refactor it to simple solution. Refactoring needs unit and other tests to see that you have not broken something without meaning. Refactoring does not mean only readable simple code. Refactoring means changing your code structure without changing its capability to simple structure. Think of this. You can cross ocean with a ship or airplane. Airplane is refactored solution. It accomplishes same thing but it is faster simpler in some places.
Education is no substitute for intelligence. That elusive quality is defined only in part by puzzle-solving ability. It is in the creation of new puzzles reflecting what your senses report that you round out the definition. Frank Herbert
|
|
|
|
|
...Your mistakes will teach you...
Persistance, tenacity, focus and self control, helping me to override my reactive frustrations which get the better of me, is key to my solutions too....
Thanx for your input
Any suggested readings, on refactoring?
ds
|
|
|
|
|
|
|
I nearly always make an interface for a class, because this keeps you thinking about what the class should do, rather than the implementation. Another advantage is that a class can be derived from multiple interfaces, so cunning class-hierachies are possible.
Develop, develop, develop....
Books: Design Patterns for C#!!!
Implement classes for Standard Things, Login, Database Access, Controls and implement them a common way, not specialized.
Split your project into logical items: Login, MdiForm, Menu {ToolBar, Treemenu, MainMenu}, Reports, MainInfo, InfoLists, Searching, New and Edit, .... Parts {Bureau, Production, ...} and split it. Most people think in a one-dimensional way (a simple line) but most programming things are Multi-Dimensional Tree-Structures!!! and trees aren't so simple to keep in mind...
You could also have a look at the Document-View Architecture in C++. There is shown how to split Data from the View of the Data.
I don't use UML because I just not used my time to learn a UML-Programm but if you can, use it!
Good luck!
Stefan Werdenberg, www.adwise.ch
|
|
|
|
|
Hi all,
Can anyone help me in giving some ideas for developing a firewall application
in vb.net
|
|
|
|
|
I understand from the on-line doc that designing a Windows Service with a GUI using C# and .NET is not possible, unless some unmanaged API are used ("Window station ?"). My aim is to have a notifyIcon associated with a Windows service: double-clicking the icon should pop up a window form with some degree of interaction: I managed to show the icon in the taskbar, no more than this.
Can anyone help ?
Thanks
Maurizio
|
|
|
|
|
In general you should avoid guis with services. Usually a service is just doing backend work. If you MUST have a GUI, and you can be sure the service doesn't need non tcp/ip network access (i.e. the service doesn't need to access network file shares), you can just set the service to run with the localsystem account and to interact with the desktop. In .NET, you can set these in the service process installer class. Otherwise you can just click the checkboxes in the SCM.
I think this will allow your GUI w/o having to muck with an unmanaged API.
Just out of curiosity as I've never come across such a scenario, why do you need the GUI to interact with the service? I'm not trying to second guess anything you're doing, I'm just curious for my own benefit.
Tim
|
|
|
|
|
Thank you Tim.
The service is already running with the LocalSystem account and the "Interact with desktop" checkbox selected, and it makes no difference, as far as I can see.
I am porting an existing enterprise application to .NET, and I would like to maintain the old scenario, where a set of services running on a server must be easily and rapidly inspected by the application administrator, by opening a log window. I know the EventLog would be the solution, but in my opinion the event viewer does not give you a "snapshot" of what's going on.
No problem to use a Windows Application instead, if the Windows Service does not fit.
Maurizio
|
|
|
|
|
Ah, that makes sense then. I had a similar situation where I had a collection of services that had to be monitored/configured by admins. I solved it by creating a very simplistic (tab control) windows form gui. I basically had a tab page for each service.
The admin would start the app. The app would communicate with the services using an appropriate ipc (I used tcp sockets, you could use remoting if you prefer). I had endpoints to the services configured in the form app (i.e. hostname and port #) -- these were persisted in the registry, in the current user hive. So I created code in the services to respond to various requests from the windows form gui i.e.,
The gui would send a request asking for the # of logged in users, the service would respond with that #.
Or,
The admin would need to point a service to a different database, so he'd make the change in the windows form app and the app would send a request to the service to make this change. The service would update the registry (local machine hive) with the new database name, etc.
Anyway, this worked well for me. Hope it helps.
Tim
|
|
|
|
|
In the end, I think I will go for something like that, Tim.
Instead of having one single tabbed form, I will probably end up with a different application for each "service", as they are quite heterogeneous.
Ciao
Maurizio
|
|
|
|
|
can anybody send me article on line segmentation and normalization of characters for ocr application
thanks in advance
saud
|
|
|
|
|
|
Can anyone write a article for "How to add Image to a PDF File using Visual C++6.
Because their is no way to add Image to PDF File...
thanks....
|
|
|
|
|
Hi everyone,
just a quick problem... i am trying to work out how to batch rename ALOT of folders based on a text file.
eg. 008456 = dharv43
i am trying to rename about 1500 student folders from their student numbers to their new logons. i have a text file of all the students numbers lined up with their logons, i just need a folder renamer that will read the data out of the file.
Thanks heaps
Dave
|
|
|
|
|
Here is the C# sample code which will help you
using System;
using System.IO;
// Read your text file with names
// Form path1 with studentname
// Form path2 with studentid
// Execute the following code in a loop
string path = "C:\xxx\xxx\" + "Studentname.txt";
string path2 = C:"\xx\xxx\" + "StudentID.txt"
if (!File.Exists(path))
{
// This statement ensures that the file is created,
// but the handle is not kept.
using (FileStream fs = File.Create(path)) {}
}
// Move the file.
File.Move(path, path2);
Console.WriteLine("{0} was moved to {1}.", path, path2);
|
|
|
|
|
Hello,
Can someone write an article about good database practices for ASP.NET applications. CP has more than a million users, if they are willing to share their secrets of optimized database code.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
i have developed a vb .exe file which generates a mschart... i need to save the mschart directly to a .bmp file without using the clipboard because it is displaying error msg "can't open clipboard" ... please help me...
|
|
|
|
|