Best guide for creating Windows Services in C# .NET? [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking to convert a small .NET console application into a Windows Service. I'd like to build two versions, one using .NET 2.0 and another with .NET 3.5 .
Are there radically different approaches that need to be taken, or will the 2.0 version be roughly equivalent to the 3.5 version? Where's a good source of information (i.e. a web-based guide) that can walk me through the steps of setting up the service?
Thanks!
P.A.

Actually, .NET 3.5 does change the C# code a little. For example, you can use the var keyword, and you can use the hidden private variables for properties. It is still based on CLR 2.0.
There is a pretty good article at msdn that talks about windows services and walks you through building one.

To supplement Rick's answer, I'd suggest the MSDN Walkthrough
It is incredibly verbose and touches on event logging as well as an installer.

The thing to remember is that .NET 3.5 is a set of additional libraries on top of .NET 2.0, so, unless you are planning on taking advantage of any additional features provided by .NET 3.5 (or .NET 3.0) like LINQ or WCF the code would be identical.
Try looking at the documentation for ServiceBase, which is the base class that you will need to inherit, to get things started.

This I believe is a decent walk through with screenshots and code samples. I think it may have been what I used for the first windows service I wrote. I think it was written back in .NET 1.1, but should still help walk you through the process. As far as the differences between 2.0 and 3.5, I would say there can/will be as much difference as you want there to be. I don't believe you will be required to change anything, but as other posters have mentioned and as you can find all over SO, there are a lot of new features that can be very beneficial that came with .NET 3.5.

There is at least one place where service code will need some attention to make it work in .net2/vs2005 vs. .net35/vs2008.
This is especially true if you write your service and installer using in c# 2.0 and compile and deploy using .net35/vs2008, the link below might save you a bit of time:
Custom Actions Changed

Here is guide to learn about windows service.

Related

.Net Core How is the documentation built if not with xml comments [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I am working with Sandcastle for a while now and I am also used to find xml inline comments in the .Net Source Reference. They usually match exactly the descriptions found on msdn.
Since .Net 4.6 and .Net Core it seems like Microsoft creates their comments differently. (Cannot find them in the .Net Source Reference anymore)
An example:
https://msdn.microsoft.com/de-de/library/system.string.padright(v=vs.110).aspx
This method has a comment in msdn but I am not able to find it in the source:
http://referencesource.microsoft.com/#mscorlib/system/string.cs,56cb688f4f1dc9e4
I am wondering how they are doing it right now with .Net 4.6 and how they will/are doing it with .NET Core. Can anyone confirm and explain this to me?
EDIT:
Since .Net Core is Open Source we should be able to figure this out. But I cannot find any information about it.
EDIT2: Since .Net Core is Open Source I think we should have access or at least be able to get access to their internal "secret" documentation tool. How else can we further develop the .Net Core and write documentation. Does anyone know that tool or where to find it?
Disclaimer Developer of MSDN engineering team, maintain both the legacy platform and the new one.
Firstly, we do have multiple document generation tools/solution for MSDN, but the core part is reflection, always. We leverage automatic tools to help extract API signatures and comments from source code, then save them in XML or Markdown files. The latest tool we are using is DocFX http://dotnet.github.io/docfx/.
Secondly, as all the API signatures and comments are stored in files, technical writers are able/allowed to modify them to make them more readable (now we have gap between source code and final product, right?). Besides, writers will add separate files, aka Conceptual Documents, to fill in description, code samples and guidance to corresponding API.
Lastly, all these files will be converted to xliff files for localization.
So in short, these documents are generated from source code comments and writers' input. The later one will be moved to GitHub later on and community contributions are welcome.
Microsoft seems to keep comments in separate files and that integrates well with their internal workflow on building MSDN and localization. Sandcastle was once a main tool used, but later made open source,
https://sandcastle.codeplex.com/
Sandcastle has been abandoned due to its complexity and the later changes in .NET Framework.
There is already a thread on CoreFX repo at GitHub to move such comments back to the C# source files but due to the tight schedule it won't happen very soon,
https://github.com/dotnet/corefx/issues/230
https://github.com/dotnet/corefx/issues/6518
And there might be some other changes on Roslyn side,
https://github.com/dotnet/roslyn/issues/85
The current documentation for .NET Core is built using DocFX,
https://dotnet.github.io/api/
which is also open source at GitHub, which should grab the comments still from the internal files,
https://github.com/dotnet/docfx
Let's see how things go in the next few months.
A sidenote is that Xamarin has its own documentation solution, and only the BCL part comes from Microsoft,
http://www.zdnet.com/article/microsofts-open-sourcing-of-net-the-back-story/
Unfortunately what system generates the current MSDN documentation for .NET Framework 4.* is unknown.

Can you programmatically interact with Component-Based Servicing (TrustedInstaller)? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have been trying to find out how to programmatically interact with Component-Based Servicing (CBS) which is basically the TrustedInstaller and other services. With the goal to be able to query CBS for what packages are installed and get any other information they may have on installed packages. Here is a link to a overview of it.
Basically using C/C++/C# (not picky) I would like to interact with this via an API. This link is the best documentation from MSDN that is API related that I could find and it isn't much. Then here is another MSDN documentation area that that gives some details but nothing really about an API I can use to interact with it. This one is under package manager which is how you can interact via command line in a limited way to install CBS based packages. The best quote from that last link is:
"CBS provides various APIs (which are
not publicly available) to its client
installers to service the operating
system components."
Which may say it all, but I am not ready to give up yet. The home for all or at least most of this is %WINDIR%\servicing which has CbsApi.dll for starters, while it appears to be registered as a COM DLL it doesn't publicly expose any classes or functions to do anything. It seems also that most of the details that the API access are in the sub-folders such as Packages, Sessions, Editions, Version, etc.
I know not many people would be trying to do this except for myself and Greg Lambert who has a couple blog posts from a two years back basically asking the same questions and trying to figure out this "not public" API. It didn't look like he cracked this nut yet either.
So now I am at the point to reach out for help and ask the community if anyone has worked out the hidden API for this, or may want to take on the challenge and see want they can find out. Any information that helps me to take a step closer is appreciated.
The correct way to programatically access the CBS is through the API's to its clients. Depending on what you are trying to accomplish, this would involve the Windows Installer or the Windows Update Agent API, both of which are documented in the Windows SDK.
The CBS instelf is an implementation detail and shouldn't be used directly. Thr reason there is so little information publically avaiable is a combination of the fact that relying on implementation details rather than contracts is a bad practice and there is simply easier and more reliable ways to accomplish anything you'd do with CBS directly.
This part of the Windows Installer SDK deals with querying for installed components.
Maybe things have changed, because I just found MS's Component Based Servicing Reference, documenting a COM interface.
Side note: I got here via a comment on Raymond Chen's blog and its response, which made wonder "what is Component Based Servicing, why is it a disaster, and what does it have to do with auto-sort?". I still don't know the answer.
Disk space filling up is a common problem in Windows 7 due to the disaster that is Component Based Servicing.
[It wouldn't be a problem if you could disable auto-sort in Explorer, though. -Raymond]
The CBS is basically for Windows Updates and other servicing operations. Since they are released by Microsoft itself, the clients of CBS are internal teams at Microsoft. The API's are not released publicly. The tools and xml files needed for writing Windows Updates, etc. are internal to Microsoft. There is no way that third party applications can use CBS technology.

choosing a diagramming library for .Net [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I have a customer who needs to convert a diagramming application (which was developed in MFC a long time ago) to C#.
The application displays large networks (lots of graphical elements), and lets the user edit/manipulate the data through a graphical ui.
I decided that it would be best to use a library rather than to develop all from scracth (all graphic objects/selection/tools/events/etc)
I am looking for a commercial solution.
I found three that seem to be very mature, and I wonder if
anyone had used them and can write his/her opinon:
Tom Sawyer Visualization
IBM ILog Diagrammer for .Net
yWorks - yFiles for .Net
thanks
Yaron
I am not familiar with this libraries, but one of my old projects we have use GoDiagram library, and can suggest that too
For making good looking diagrams in .Net you should check out Frank Hileman's VG.Net. He's a reputed MVP and I believe his solution is really good:
http://www.vgdotnet.com/
I recommend MindFusion's Flowchart.NET. It's very easy to use and is very affordable considering it comes with a multitude of powerful layouting algorithms. Previously we used GoDiagram, but I recommend against it because their licensing system is a nightmare if you have build machines, and it's much more expensive.
I believe Dundas charts is the most famous one...or at least the most advertised one:
http://www.dundas.com/Microsite/ChartNET/Default.aspx?Campaign=GoogleCSharpChart&gclid=CM-wncOq354CFUmK3godxENfMQ
I know this probably isn't the best solution but I'm going to put it out there anyway.
I've done something similar to this using .Net's System.ComponenetModel.DesignSurface. This is the same design service used in Visual Studio's Windows Forms so all you do is create your controls, add your control designers if you want and you're good to go. You can use the PropertyGrid to display the data for each object as they are selected. Code Project has several articles about this like this one.
That said it's not going to be the best performance wise, I've got several thousand controls on my DesignSurface in some cases and it gets sluggish. You may be able to get around this by using another root designer type (WPF maybe?).
This could be a very good option if you already know how to do custom Windows Forms controls. And best of all it’s free!
Have a look at Orbifold. They have got WPF based solutions (commercial) or libraries supporting GDI+ (free).
It's also a good starting point for information about diagramming algorithms in general.

Where can I learn to build desktop applications with C#? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
My background is in web programming, mostly scripting with Perl. And I've recently been tasked with creating a desktop application. I'm wondering, where can one learn such concepts like making executables, what DLLs are for, how UIs are made, what threads are, etc.
I already have C# in Depth by Jon Skeet and C# in a Nutshell. I'm not worried about learning C# itself as much as I am learning about the workflows involved with using it on the desktop, things that are typically not done in web development.
Where should I look?
One starting point would be WindowsClient.net (Microsoft). Lots of videos too. But maybe a little less suited for the absolute beginners.
I only recently began learning C# myself - so I have quite the array(... ;) ) of links:
C-Sharp Corner
CSharp Friends
CSharp Help
CSharp for absolute beginners - Very good
CSharp-online
Hope these help.
For learning .NET application development (the only way people should write apps on windows boxes without requirements otherwise), start with the excellent book CLR Via C# by Jeffrey Richter. Save the first couple chapters for later. You'll get everything you need to know about C# and the 2.0 CLR, which is the basis of all .NET application development (in C#, anyhow.)
Once you're done with that, look into Linq. Linq covers a number of different language feature updates that came in 3.0 and 3.5 versions of the framework and their associated language updates. With the basics + a good understanding of Linq, you'll be creating decent apps in no time.
Now, for which framework to use when constructing desktop apps: Winforms, or WPF.
If you're a web developer, throw that old winforms crap away and get with WPF. You'll feel much more comfortable with editing WPF forms in xaml than dealing with winforms.
The best thing about WPF is the amazing databinding support. In fact, the WPF version of MVC is based on the databinding support in WPF.
Check out the databinding cheat sheet, then learn about MVVM.
A good place to start would be to read MCTS Exam 70-546 Windows-based client development, then read 70-548 Designing and Developing Windows-based application. After that, you will probably need to read books focused on the specific technologies your app will use.
Surprised no one has answered this yet:
Programming Windows With C#, by Charles Petzold. Great book, easy read. Example based, but well organized for people that want to jump directly to a particular topic. He actually explains what's going on in each example, and why he's doing what he's doing. Really, a great resource.
(Note: this is a Windows Forms book...no WPF. Great for what it does, but if you're looking for WPF, look elsewhere.)
Old question, but i had to learn the same thing recently. I got the Visual C# 2012 step by step book. It teaches C# along with WPM. A good way to learn.
From what I hear and the little I have read of it Chris Sells's book on WinForms would be useful that. If I am not mistaken he has also done a book on WPF, but I don't know if it is any good.
Check Windows Developer Training Resources and for sure you will need the help of a book and some videos
You can start by building a new project in Visual Studio and selecting the one of the project templates under C#\Windows. This will build a simple application so you can see the basic elements of the project. For example select 'Windows Forms Application' this will start you off with a form where you can drag and drop additional page elements. You can then use Intellisence to explore the options on the controls. Also load the sample projects so you can see working examples.
That's how I would do it.
I recommend you the C# Yellow Book (Rob Miles) it's free and very useful to learn C# basics fast.

Mono Compatible Networking/Socket Library [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Are there any Mono (C#) compatible networking / socket libraries out there?
Preferably something that is:
Multi Threaded
Event Driven
Capable of multiple connections
Handles client and server pieces
Runs on Mono and MS .NET runtimes
Very simple
Free (And usable in commercial software)
It would also be really great if it was:
.NET Compact Framework (Windows Mobile) compatible
MonoTouch (iPhone) compatible
Edit:
To clarify more, what I meant by my "one level above TCP/IP" comment was that I want something that is basically a self contained server / client. I don't want to have to deal with writing the threading code, handling each connection, etc. For example, I would love for the code to look like this:
Server s = new Server(8080);
s.NewConnection += new ConnectionEventHandler(NewConnection);
s.DataRecieved += new DataEventHandler(NewData);
s.Start();
void NewConnection(object sender, EventArgs e)
{
s.Send((Connection)sender, "Hello World!"); //(Connection)sender is the connection instance so the server knows which to send the response to
}
void NewData(object sender, EventArgs e)
{
s.Send((Connection)sender, e.Data); //Echo back
}
Not the cleanest code, but I think it gives the basic idea.
Something like this now exists, checkout networkComms.net. Does all of the things you require and is also 100% compatible with mono.
Disclaimer: I am one of the developers for this commercial library.
No, there is nothing out of the box that does what you want.
TcpClient/TcpListenr are already one level above Socket class. If you really want something that is even simpler, it is a very easy task to wrap TcpListener() and make it expose the event handler entry points that you want.
You should check out RemotingLite. I use it with my Mono applications. It was developed to aid in the networking aspect of the Distributed Computing Library MPAPI. MPAPI had a goal of being 100% compatible with Mono.
I am not clear as to what exactly you expect from a class that is "one level above TcpClient and TcpListener"?
TcpClient/TcpListener are the basic building blocks you should use for development. I am not sure if they are supported in Mono as well, but if they are, then it should be all you need.
.Net CompactFramework also supports these, although I am not sure about Mono Touch.

Categories

Resources