Close AD

Chintan Patel's Blog
Home | Archive | Photo Albums | Links | Contact Sign In | Sign Up

About Author

Chintankumar Patel
09 Jun, 2008

Contact Me  

Working as a Technical Consultant for Conchango.

Having experience in to IT from 7+ years and working on Microsoft Technologies

Archive

2009 Dec   (1)
2008 Dec   (1)
2008 Oct   (3)
2008 Sep   (6)
2008 Aug   (1)
2008 Jul   (2)
2008 Jun   (7)

Recent Posts

Windows 7 review
Comments : 0
Not Rated  
Disable System Restore in Windows Vista
Comments : 3
Not Rated  
What's New in the .NET Framework 2.0 ?
Comments : 2
Not Rated  
How to work with partitions in Windows Vista / XP when Disk Management doesn’t work
Comments : 3
Not Rated  
How to resize a partition in Windows Vista?
Comments : 3
Not Rated  
Top 10 tricks for handling null values in Microsoft Office Access
Comments : 17
Not Rated  
What is Vista's ReadyBoost and SuperFetch Technology
Comments : 5
Not Rated  
What is YouTube? - An introduction to the YouTube.com
Comments : 5
Not Rated  
SQL DATEDIFF Function - Applies to MS SQL Server and MS Office Access
Comments : 4
Not Rated  
Booting from USB Pen/Key/Flash Drive (Windows/Linux)
Comments : 5
Not Rated  

Categories

.Net Graphics   (2)
.Net Technology   (6)
ASP.Net   (1)
General   (2)
Microsoft Access   (1)
Microsoft Visual Studio   (1)
Microsoft Windows   (4)
SQL   (1)
USB   (1)
Windows 7   (1)
Windows Vista   (2)

Tags

.Net , .Net Framework 2.0 , .Net Graphics , Asp.Net , Boot , C# , Class Library , Coding Standards , Convert File System , Database , DATEDIFF , DATEDIFF Function , Disk Management , Embedded Resources , EnableEventValidation , EnableViewState , EncoderParameter , FAT32 to NTFS , Form Authentication , HDD , High Quality Thumbnail , Intellisense , Linux , Microsoft Access , Microsoft's SQL , Partition , ReadyBoost , ReSharper , Resize Image , Resize Partition , Security , SQLDataReader , SuperFetch , System Restore , USB , Usb device not recognized , Vista , Visual Studio 2005 , What's New , Windows , Windows 7 , Windows Application , Windows Errors , Windows Vista , Windows XP , YouTube

2008 Jul (2 Posts)

Usb device not recognized - One of the USB devices attached to this computer has malfunctioned : Windows XP Error

Fri, 25 Jul, 2008

 

The Problem

While reconnecting the USB device you may face the following error
The contents of the error message in the little message balloon says

"Usb device not recognized"
"One of the USB devices attached to this computer has malfunctioned, and Windows does not recognize it. For assistance in solving this problem, click this message."

If you try clicking the message but the troubleshooting assistance is of no help

I tried it on several Windows 2000 machines and two other Windows XP machines and it worked on all of them, so I concluded that it had something to do with computer rather than my hopes that it was just a faulty flash drive that I could exchange to solve the problem.

I did some research online and learned that sometimes the USB ports located on the front of the case don’t have enough power for some USB devices. Sure enough, when I tried copying the exact same directory with the flash drive plugged into one of the USB ports in the back, it worked several times in a row.

The Solution

Here is the solution that worked for me...

1) Remove all oem*.inf files

    1. Click start and click run then under the run line type in the command "cmd" (without the quotation marks)
    2. In the command line, type in the following (without the quotes) and press enter after each command:
       "cd \windows\inf"
       "ren infcache.1 *.old"
       "ren oem*.inf *.old"
       "del C:\windows\setupapi.log"


2) Removing all entries under HKEY_LOCAL_MACHINE/Enum/USB that start with "VID"

     Removing the VID entries from the registry will cause them to be redetected at restart.
    CAUTION: If you have a USB keyboard or mouse, do not remove the VID entry for these devices, otherwise, Windows may not restart correctly.

    1. Click Start and click Run. Type regedit and click OK. The Registry Editor window will open.
    2. Go to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\USB.
    3. Highlight and delete all the VID_…. entries.
       Permissions may be set allowing the deletion of the VID_ entries by following the steps below:
       a)Right-click the key to be deleted, and then click Permissions. The VID_… Permissions window will open.
       b)With Everyone highlighted in the Group or User name section, select Full Control in the Permissions section.
       c)Click Apply, and then click OK.
    4. Turn off the computer.

3) Reconnect the USB device to the computer system: 

    1. With the computer system turned off, reconnect the USB hub to the the USB port.
    2. Restart the computer.
    3. A New Hardware Detected window should open and reload the drivers.

  

.Net Coding Standards/Guidelines (C# .Net)

Tue, 15 Jul, 2008

Table of Contents

1. Introduction

2. Style Guidelines

2.1 Tabs & Indenting

2.2 Bracing

2.3 Commenting

2.3.1 Documentation Comments

2.3.2 Comment Style

2.4 Spacing

2.5 Naming

2.6 Naming Conventions

2.6.1 Interop Classes

2.7 File Organization

1. Introduction

First, read the .NET Framework Design Guidelines. Almost all naming conventions, casing rules, etc., are spelled out in this document. Unlike the Design Guidelines document, you should treat this document as a set of suggested guidelines. These generally do not effect the customer view so they are not required.

2. Style Guidelines

2.1 Tabs & Indenting

Tab characters (\0x09) should not be used in code. All indentation should be done with 4 space characters.

2.2 Bracing

Open braces should always be at the beginning of the line after the statement that begins the block. Contents of the brace should be indented by 4 spaces. For example:

if (someExpression)
{
DoSomething();
}
else
{
DoSomethingElse();
}

“case” statements should be indented from the switch statement like this:

switch (someExpression)
{

case 0:
DoSomething();
break;

case 1:
DoSomethingElse();
break;

case 2:
{
int n = 1;
DoAnotherThing(n);
}
break;
}

Braces should never be considered optional. Even for single statement blocks, you should always use braces. This increases code readability and maintainability.

for (int i=0; i<100; i++) { DoSomething(i); }

2.3 Single line statements

Single line statements can have braces that begin and end on the same line.

public class Foo
{
int bar;

public int Bar
{
get { return bar; }
set { bar = value; }
}

}

It is suggested that all control structures (if, while, for, etc.) use braces, but it is not required.

2.4 Commenting

Comments should be used to describe intention, algorithmic overview, and/or logical flow. It would be ideal, if from reading the comments alone, someone other than the author could understand a function’s intended behavior and general operation. While there are no minimum comment requirements and certainly some very small routines need no commenting at all, it is hoped that most routines will have comments reflecting the programmer’s intent and approach.

2.4.1 Copyright notice

Each file should start with a copyright notice. To avoid errors in doc comment builds, you don’t want to use triple-slash doc comments, but using XML makes the comments easy to replace in the future. Final text will vary by product (you should contact legal for the exact text), but should be similar to:

//-----------------------------------------------------------------------
// <copyright file="ContainerControl.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

2.4.2 Documentation Comments

All methods should use XML doc comments. For internal dev comments, the <devdoc> tag should be used.

public class Foo
{

/// <summary>Public stuff about the method</summary>
/// <param name=”bar”>What a neat parameter!</param>
/// <devdoc>Cool internal stuff!</devdoc>
///
public void MyMethod(int bar) { … }

}

However, it is common that you would want to move the XML documentation to an external file – for that, use the <include> tag.

public class Foo
{

/// <include file='doc\Foo.uex' path='docs/doc[@for="Foo.MyMethod"]/*' />
///
public void MyMethod(int bar) { … }

}

UNDONE§ there is a big doc with all the comment tags we should be using… where is that?

2.4.3 Comment Style

The // (two slashes) style of comment tags should be used in most situations. Where ever possible, place comments above the code instead of beside it. Here are some examples:

// This is required for WebClient to work through the proxy
GlobalProxySelection.Select = new WebProxy("http://itgproxy");

// Create object to access Internet resources
//
WebClient myClient = new WebClient();

Comments can be placed at the end of a line when space allows:

public class SomethingUseful
{
private int itemHash; // instance member
private static bool hasDoneSomething; // static member
}

2.5 Spacing

Spaces improve readability by decreasing code density. Here are some guidelines for the use of space characters within code:

  • Do use a single space after a comma between function arguments.
    Right: Console.In.Read(myChar, 0, 1);
    Wrong: Console.In.Read(myChar,0,1);
  • Do not use a space after the parenthesis and function arguments
    Right: CreateFoo(myChar, 0, 1)
    Wrong: CreateFoo( myChar, 0, 1 )
  • Do not use spaces between a function name and parenthesis.
    Right: CreateFoo()
    Wrong: CreateFoo ()
  • Do not use spaces inside brackets.
    Right: x = dataArray[index];
    Wrong: x = dataArray[ index ];
  • Do use a single space before flow control statements
    Right: while (x == y)
    Wrong: while(x==y)
  • Do use a single space before and after comparison operators
    Right: if (x == y)
    Wrong: if (x==y)
2.6 Naming

Follow all .NET Framework Design Guidelines for both internal and external members. Highlights of these include:

  • Do not use Hungarian notation
  • Do not use a prefix for member variables (_, m_, s_, etc.). If you want to distinguish between local and member variables you should use “this.” in C# and “Me.” in VB.NET.
  • Do use camelCasing for member variables
  • Do use camelCasing for parameters
  • Do use camelCasing for local variables
  • Do use PascalCasing for function, property, event, and class names
  • Do prefix interfaces names with “I”
  • Do not prefix enums, classes, or delegates with any letter

The reasons to extend the public rules (no Hungarian, no prefix for member variables, etc.) is to produce a consistent source code appearance. In addition a goal is to have clean readable source. Code legibility should be a primary goal.

2.7 Naming Conventions
2.7.1 Interop Classes

Classes that are there for interop wrappers (DllImport statements) should follow the naming convention below:

  • NativeMethods – No suppress unmanaged code attribute, these are methods that can be used anywhere because a stack walk will be performed.
  • UnsafeNativeMethods – Has suppress unmanaged code attribute. These methods are potentially dangerous and any caller of these methods must do a full security review to ensure that the usage is safe and protected as no stack walk will be performed.
  • SafeNativeMethods – Has suppress unmanaged code attribute. These methods are safe and can be used fairly safely and the caller isn’t needed to do full security reviews even though no stack walk will be performed.

class NativeMethods
{
private NativeMethods() {}

[DllImport(“user32”)]
internal static extern void FormatHardDrive(string driveName);
}

[SuppressUnmanagedCode]
class UnsafeNativeMethods
{
private UnsafeNativeMethods() {}

[DllImport(“user32”)]
internal static extern void CreateFile(string fileName);
}

[SuppressUnmanagedCode]
class SafeNativeMethods
{
private SafeNativeMethods() {}

[DllImport(“user32”)]
internal static extern void MessageBox(string text);
}

All interop classes must be private, and all methods must be internal . In addition a private constructor should be provided to prevent instantiation.

2.8 File Organization
  • Source files should contain only one public type, although multiple internal classes are allowed
  • Source files should be given the name of the public class in the file
  • Directory names should follow the namespace for the class

For example, I would expect to find the public class “System.Windows.Forms.Control” in “System\Windows\Forms\Control.cs”…

  • Classes member should be alphabetized , and grouped into sections (Fields, Constructors, Properties, Events, Methods, Private interface implementations, Nested types)
  • Using statements should be inside the namespace declaration.

namespace MyNamespace
{

using System;

public class MyClass : IFoo
{

// fields
int foo;

// constructors
public MyClass() { … }

// properties
public int Foo { get { … } set { … } }

// events
public event EventHandler FooChanged { add { … } remove { … } }

// methods
void DoSomething() { … }
void FindSomethind() { … }

//private interface implementations
void IFoo.DoSomething() { DoSomething(); }

// nested types
class NestedType { … }

}

}

Advertisement
Car Insurance - Compare Motor Insurance Quotes
Saga Car Insurance Post Office Car Insurance Prudential Car Insurance
Elephant Car insurance Privilege Car Insurance Esure Car Insurance

Original article posted by http://www.misfitgeek.com/


  

Powered by NineOn Inc.