C# namespace search - c#

I'm new to c# and I'm always Googling to find namespaces. Is there a better way, a namespace search page or something like that?
Thanks

Are you looking for the .NET Class Library: http://msdn.microsoft.com/en-us/library/ms229335.aspx

If you're using visual studio (express) you can simply use the help (either locally, or it will redirect you to the msdn website).
On the other hand I've often found that if a site offers exactly the information you look for, it's often easier to use google than the sites build in search functions :-)

There's a nice list of all namespaces in the .NET libraries on MSDN.

You could try the Resharper plugin
If you're a student or developing open source projects, it's free

Are you referring to finding the right DLL for a given namespace? Some namespaces are spread amongst several DLLs. Each class page on MSDN will list which DLL that class is in. E.G. The DataContractAttribute class is in the System.Runtime.Serialization.dll.

Related

How do I find which nested namespace to import in C# for the classes I need in my code?

This is one of the things I find infuriating about C#. I have thsi massive library im trying to use right now and for some reason the people who create the code examples are not smart enough to include the namespaces you need to import in the examples. This is usualyl the case. I find myself searching through the namespace, hundreds sometimes nested trying to figure out which ones i need to import. In java netbeans, it even tells me which packages to import because it searches for me. But in C# i always waste countless time searching through the namespace manually.
Is there any way I can get around this. Like right now im trying to find which namespace contains TwitterCredentials for Tweetinvi library.
Seriously, why do people not include the namespace in code examples. It's just stupid not to!
And why does visual studio not make suggestions like java. It's just common sense really....
You can press Ctrl + . on each word that has error or point to small blue bar under the word and click on dropdown, and use offered namespace.
I am the developer of Tweetinvi :)
ALL the classes you need in Tweetinvi are located in the Tweetinvi.Core.* namespace.
TwitterCredentials.cs
To answer your question regarding Namespaces and why I do not include them in the examples. The reason is that as mentioned by Reza Aghaei Visual Studio and Resharper allow developers to include namespaces.
Furthermore as you mentioned the library is big and therefore multiple namespaces might be required and I am not going to add all of them in each example. Otherwise the documentation would just be huge.
I hope you will like the library and please feel free to ask any question here on stackoverflow or on github.
Happy coding.
PS: By the way you can also use Github to search for filename with a 't' keystroke on the Source Code page.

Add-ons for your C# app

I have a C# program and I want to make it able to load addons. Addons are like that: You pass a control or form to it and it makes some changes to them.
Is there anyway to have dll addons and load them dynamically at runtime and pass controls??
If not Any Idea? What should I do?
Look into MEF to load and import the assemblies and the controls.
Look at Management Extensibility Framework.
Yes that's possible and it works similar to other programming languages: Load the library and call methods to get names and stuff. One possible solution can be found in this question.

c#-doc-viewer for VisualStudio

c# offers a nice way to document your c#-code. But I don´t find any nice viewer. I search something like the java-doc-viewer in eclipse. This viewer allows you to browse in the java-doc just by moving your mouse over eg. a class-name.
Does someone know a good extension for Visual Studio 2010 that contains such a viewer?
I have the "Productivity Power Tools"-Extension installed. But it hasn´t a real doc-viewer either.
Edit:
Here is a picture of what I search:
And this is the best I can find for VisualStudio:
You try using CR_Documentor, if you don't mind installing Code Rush (alone for that purpose; you only need the free "DXCore" actually, checkout the project's homepage for more information).
Note that this tool doesn't require a prior generation of the documentation using tools like Sandcastle. It works by simply placing your cursor in a API comment block, e.g. that of a method.
Obviously, this has some drawbacks, for example, links to other items (e.g. <see/> or <seealso> will be rendered as a link, but don't work as such).
This is what it looks like:
I was using it once, way back when it was still maintained by the original author Lutz Roeder, and it did it's job well. I have not been using it since.
Update: You could also use ReSharper, which provides a "Quick Documentation" feature.
There isn't any built-in tool in VS for viewing the documentation of your code. You have to generate the documentation pages from the XML doc, using external tools.
Free tools:
Sandcastle is the most well known, it has a lot of features, but it doesn't seem to be maintained any more and it's quite difficult to use (although Sandcastle Help File Builder makes it significantly easier, and is still maintained).
docu is simpler to use, but not specific to .NET
Monodoc (from the Mono project)
Commercial tools:
VSdocman
Document! X
Doc-O-Matic
ForgeDoc: this one is quite new and looks very promising: very lightweight, simple to use, fast, good-looking output... It's also much cheaper than the others above
You can use NDoc to build the API documentation and generate help files (typically HTML files)
http://sourceforge.net/projects/ndoc/

Possible to inject resource files into .net assembly?

There's a .net program for students that I've been messing around with in Reflector and Reflexil, but it doesn't look like they can work with resource files. I want to replace the default background with a custom one. How feasible is this?
I've tried exporting the assembly as a C# project and maybe rebuilding with the resource files swapped, but a few classes won't decompile right when exporting and crashes Reflector when I try to view the full source code inside reflector (after clicking 'expand methods')
What type of applicaiton is it? WinForms, WPF, Silverlight, Web? You can do it with ILDasm round triping. If you let me know what type of app it is I'll post the steps you need to take.
Reflexil 1.3 is now able to handle resources.
Quite difficult, probably Hex Editor can help.
Resource Hacker can do it. Follow; Action > Add a new Resource
delphi.icm.edu.pl/ftp/tools/ResHack.zip
I just put out GrayWolf to edit programs, I don't have the ability to edit resource(s) (if you donate$:) yet
but I would think the easy change is to edit the program to load the background from disk (./back1.jpg)
I have others tools that would make it easy to change the background of the running program see
"Hacking .NET" at DefCon18
other tools "GrayDragon"
I have a payload that does just this, it is for DefCon19, but if you send me an e-mail...
Happy hunting

ASP.net c#, how do I know what to use?

I keep coming accross code samples online for ASP.net c#, however they never seem to list which namespaces they include, for example:
using System.Data.SqlClient;
etc etc
Am I missing something obvious or should I be expected to know exactly what namespaces each code example requires?
When I'm in that situation, typically I search for the class on MSDN. The documentation will tell you which namespaces contain the class.
If they don't include them, you can follow this list in order:
Find that they are in one of the namespaces listed in the "blank code file" template , or
In Visual Studio You can click the missing type and press shift+F10 or Ctrl+. To get the option to automatically add the using statement (if the assembly is referenced)
With Resharper, Select the type and hit alt+enter for Resharper to find the namespace for you, and add it to the usings (possibly even reference the assembly as well)
Go to MSDN and search the name.
Go to Google and search the name (honestly, I normally do this before hitting MSDN anyway)
Compain to the article author
If code samples use the assemblies that a project references by default, then you can hover on the class name and click shift+F10 which will add the using statement automatically. If the class is not in any of the referenced assemblies then you are out of luck and need to know in what assembly does the class resides.
A quick google search can help, and in time you will memorize the namespaces... Of course its best if samples included the namespace and reference info, but mostly they do not.
If you are viewing code in Visual studio, just hover mouse over class or object you want and you will get tool tip about it if assemly of that class is present or you can google for particular class.For example if you want to know more about 'DataTable'class, just google it and you will come to know that its part of Syste.Data namespace.
I'm with the OP on this one. Having to just magically "know" what namespaces are required seems supremely silly.
I spent some time before C# as a Java Developer, and the NetBeans IDE will resolve these for you automatically. Ctrl-Shift-I, and it will insert all the packages (ie, namespaces) you need. If more than one package defines the class you are resolving, a window pops up and lets you choose which one you want.
For as fine a product as VS is, I am incredulous that this feature is not included.

Categories