Skip to main content

Posts

Visual Studio Extensibility

http://feeds.delicious.com/rss/learnerplates/extensibility Extending the Visual Studio IDE means adding custom functionality to the IDE, this could be custom TextEditors, Add Ins to the Tools menu, Writing to the Output Console, basically anything that will require you to add or write to any component in the Visual Studio IDE. Extending the Visual Studio IDE is not for the faint hearted. It is implemented with a Visual Studio Extensibility SDK downloadable from link 1 below. It's implemented using COM interfaces (not very nice). There are 5 points of contact for Extensibility issues 1. MSDN Visual Studio SDK homepage. 2. MSDN documentation. 3. MSDN Extensibility Forum . 4. Dr. Ex's Weblog . 5. MZ-Tools. There are also webcasts available from msdn . I recommend watching some of the webcasts especially the Managed Package Framework as the explain briefly how some of the Class Attributes work with RegPkg.exe and how important the GUIDs are. GUIDs The GUIDs are static and each con...

ASP.NET, terms, filetypes, examples

http://feeds.delicious.com/rss/learnerplates/httpmodule http://feeds.delicious.com/rss/learnerplates/httphandler ASP.NET is the .NET version of ASP, this new version adds more functionality. ASP and ASP.NET are web development frameworks which allow you the developer to access and manipulate HTML before Posting it up to the client. Both frameworks allow you to access HTML controls (e.g. TextField) using the directive "script runat="server"" . This gives you a reference to the HTML control, that the user sees in their browser, from the server side. You also have control over the Http Requests and Responses, allowing you to analyze responses sent back, errors and cookies etc can be transmitted over HTTP. ASP was lacking in that you could not separate the scripting logic from the HTML front end of the file. ASP.NET allows you to move your logic (written in any .NET language) to a separate file, this is referred to as CodeBehind. The codebehind can be accessed in the as...

dotNET - Lists comparisons and Predicates

Here's something I've found very useful but at first found very difficult to understand. When trying to find certain contents of a list you have a few options open to you. The first is to enumerate through the list and do a comparison of each value in the list, this is the old way to do things: foreach (string sf in sourceFiles) { if (sf.Contains("DBAccess.js")) containsDBAccess = true; } .NET has provided a better implementation using Predicates. Predicates are implemented with delegates. You implement your Predicate with with a Function which takes a single parameter, a string, and returns bool. e.g. private static bool FindDBAccess(string s) { return s.Contains("DBAccess.js"); } and use this in the List.Find like so if (sourceFiles.Find(FindDBAccess) == null) {........ } The string 's' passed as a para...

dotNET - CLR Profiling and memory management

The .NET CLR manages the memory allocated by .NET managed applications. The CLR implements Garbage Collection. This GC can run into problems and may not run as well as it should if you implement your applications in certain ways. GC problems may manifest themselves as a slowdown in the application, this maybe due to the GC spending time trying to manage memory which is fragmented, in very large segments or objects with many references. The CLR manages the memory by using a pointer to the memory addresses, these pointers must do alot of work particularly if an object has many references, each reference requires a pointer. You can invoke the GC with the System.GC class. GC.collect(). There are some tools and code classes available to monitor memory. One of these is a class called Perfmon (performance monitor), to use this you add a Perfmon instance in your class, this instance gets incremented each time the GC gets used on that object. You may then query the Perfmon object to find which ...

dotNET - Protect IP, Obfuscation (Obfuscate)

Obfuscation is a methodology to make it more difficult to reverse-engineer your assemblies. It's achieved by scrambling and removing some of the contents of the assembly. Scrambling maybe just renaming of methods (it does not rename methods which are public to other assemblies outside). It may also remove unnecessary Metadata such as Property descriptors. There are various levels of Obfuscation and these can all be set in the Obfuscation application of your choice. Obfuscated assemblies maybe accompanied by a Map file, a kind of settings file for the Obfuscation application.This map file may contain the renaming pattern you have used and is input to the Obfuscator application, it is useful if you wish to patch a system with say one assembly, and you want your new assembly to be obfuscated in the same way as the application. Under Construction Thwart Reverse Engineering of Your Visual Basic .NET or C# Code

dotNET - Debugging

Debugging with .NET MSIL assemblies Visual Studio and debugging the CLR are different, I'll talk about both. MSIL Assemblies Assemblies compiled with .NET tools such as the CLR compiler are compiled into a file which contains MSIL (Microsoft Intermediate Language). At runtime the contents of the assembly are loaded into the CLR and ran as machine code. When you compile an assembly in debug a PDB file is generated alongside the DLL or EXE you've just created. The link between these 2 files is that the PDB contains the line numbers of the methods and classes as well as the file names of the original source code that created the assembly. When you launch the debugger in Visual Studio the assembly is loaded into the Debugger (similar to the CLR) along with the PDB file. The debugger now uses your PDB file contents to match the running code found in the assembly to locations in source files (hopefully in your present project). CLR CLR Inside Out (msdn magazine) .NET Framework Tools:...

dotNET - Use app.config ApplicationSettings and UserSettings

When using Settings in an Assembly or .exe you can use the Settings Designer to generate a config file using Settings. The Settings Designer provides a wrapper class which allows you to provide defaults and access the config data using Properties. But what if you're not working inside that Assembly or .exe? this presents a problem. If your loading the Assembly externally and want to access that Assembly's .config file you'll probably wish to use something in the System.Configuration namespace... unfortunately it's not of much use if you've created the .config file from the Settings Designer in Visual Studio!! This is because the Designer creates Sections and ApplicationSettings and UserSettings, the System.Configuration namespace does not provide a method to access these (it has a method to access AppSettings which are a different thing. Below I've written a workaround which locates the app.config and accesses the ApplicationSettings and UserSettings using XML i...

Windows Miscellaneous

Virtual PC Creating a Virtual PC using another machines Virtual Hard Disk Make a copy of the other machines .vhd file. Copy to the local machine and point the new Virtual PC to the .vhd. SID will have to be run on the new Virtual PC in order to change the name of the machine, as it will still have the name of the original machine the vhd was taken from. http://www.microsoft.com/technet/sysinternals/Security/NewSid.mspx HTML DOM Inspector http://www.sharewareconnection.com/download-ie-dom-inspector-from-sharecon.html

dotNET - VS 2005 Web Deployment Projects + Installer (MSI) creation

You've got your Web Project in Visual Studio and you want to create a way to provide it as an installation. There are 2 ways to do this: 1. Create a Web Deployment Project from your Web Project and then use the output of this as the input to another project, a Setup Project. After you've achieved this you'll have an MSI installer file which has configurable elements, these configurable elements will be dictated by yourself when creating the Web Deployment Project and the Setup Project. 2. Create a WebSetup project from your Web Project. After you've achieved this you'll have an MSI installer file. Option 2 is the simpler option. The difference between the 2 options is that the first provides extra control using the Deployment project, such things a MSBuild and assembly type deployment. If you choose option 1 then: You can quickly create a Web Deployment Project by right-clicking the Web Project in the Visual Studio Solution Explorer. This will copy the contents of y...

IIS admininstration Miscellaneous

http://feeds.delicious.com/rss/learnerplates/iis How to access the IIS Metadase programmatically. Parser for IIS logs A script to extract data from log files (can be IIS log files) using SQL Query format. http://www.microsoft.com/technet/community/columns/profwin/pw0505.mspx The script can be downloaded at http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en

Cookies and FormsAuthentication

Cookies Cookies are simply a file stored in the client machine which are sent up and down to and from the server with every Request and Response. The Cookie is used to store some client information such as details of their past session. It allows the Client to return to a webpage and have information already available to them without having to start from scratch. The Cookie is first sent down from the Server and is stored somewhere on the Client's hard-drive. It's up to the Web Application developer to do the Cookie processing on the Server side. The Cookie can be accessed from the Request as the Cookie is a property of the HttpRequest, Request.Cookie["cookiename"]; One problem I've encountered with Cookies is that all the cookies associated with your application get Posted from the Client on each Request, this adds to the amount of data sent as you can imagine. There is a solution however, in order to ensure a Cookie is only sent from Client to Server when a cert...

Setup Programs Installer creation using VS2005

Setup Programs Installer creation using VS2005 Getting Started with Setup Projects (SimpleTalk). Visual Studio Setup Projects and Custom Actions (Simple Talk). Updates to Setup Projects (SimpleTalk). To create an Installer using Visual Studio you must create a Setup Project. A setup project contents are files and outputs of other projects in the solution. The Setup Project template can be found in the Visual Studio New Project dialog under Other Projects->Setup and Deployment->Setup Project. Tip! To debug installation or just see what's happening in the background and view system variable values use the msiexec logger, it logs everything that's happening on installation, it can also be used for uninstall install: msiexec /i yourinstaller .msi /l* yourinstaller .log or verbose msiexec /i yourinstaller .msi /l*v yourinstaller .log uninstall: msiexec /uninstall yourinstaller .msi /l* yourinstaller .log or verbose msiexec /uninstall yourinstaller .msi /l*v yourinstaller .lo...

Miscellaneous

New Assignment instead of Virtual/Override The "new" keyword can be used with methods, it provides a type of inheritance similar to polymorphism. class Program { static void Main(string[] args) { BaseClass bc = new BaseClass(); ChildClass cc = new ChildClass(); bc.Foo(); bc.Bar(); Console.WriteLine("======================="); ((BaseClass)cc).Foo(); ((BaseClass)cc).Bar(); Console.WriteLine("======================="); cc.Foo(); cc.Bar(); Console.WriteLine("======================="); Console.ReadLine(); } } class BaseClass { public void Foo() { Console.WriteLine("BaseClass.Foo"); } public virtual void Bar() { Console.WriteLine("BaseClass.Bar"); } } class ChildClass : BaseClass { new public void Foo() { ...