It’s very common for developer to generate a GUID in code to guarantee uniqueness. Here is the sample code to generate a GUID in Perl
my $guid = `uuidgen.exe`;
Uuuidgen.exe is a tool from DotNet Framework. You can append "-c" option to generate uppercase letters
Run uuidgen /? to see the detail usage of uuidgen.
Microsoft UUID Generator v1.01 Copyright (c) Microsoft Corporation. All rights reserved.
usage: uuidgen [-xisconvh?]
x – Generate sequential (V1) UUIDs
i – Output UUID in an IDL interface template
s – Output UUID as an initialized C struct
c – Output UUID in upper case
o<filename> – redirect output to a file, specified immediately after o
n<number> – Number of UUIDs to generate, specified immediately after n
v – display version information about uuidgen
h,? – Display command option summary
When you use MSBuild, a handful of properties are available to you out of the box that cannot be modified. These are known as reserved properties. Following table presents all reserved properties in MSBuild 4.
If you build a web application with Chart control for ASP.NET 4.0 and deploy the site to web server. You might get following error on the live site:
The temp directory in chart handler configuration is not accessible
To resolve this, first go to web.config and find the ChartImage directory in appsettings.
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:TempImageFiles;" />
The go to the temp chart image directory and grant read and write permission to IIS working process account in share properties – security tab. Note that the account runs IIS working process is different between IIS 7 and IIS 7.5
- On Windows Server 2008 has IIS7, grant Read and Write permission to Network Service
- On Windows server 2008 R2 has IIS 7.5, grant Read and Write permission to AppPool<PoolName>. Replace <PoolName> to the actual machine pool your site is running on, for example, if your site is running on pool named ASP.NET v4.0, then the account you need grant permission would be IIS AppPoolASP.NET v4.0, you can refer this step by step instructions for detail
Visual Studio has a great feature to easily remove all dead using statements in your code.
The steps are pretty straightforward.
- Right click anywhere from the code
- Select Organize Using and
- Select Remove Unused Usings.
There are two versions of the TraceWrapper.dll in SCVMM install CD. One is x86 version and the other is x64 version. When you build your application on top of SCVMM library Microsoft.SystemCenter.VirtualMachineManager, it’s very important to pick up the correct version TraceWrapper.dll. In general, you should copy the 32 bit dll if you are using 32 bit system, copy 64 bit dll if you are using 64 bit system. Otherwise following BadImageFormatException would occur during runtime.
Could not load file or assembly ‘TraceWrapper, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. An attempt was made to load a program with an incorrect format.
However, you should keep using 32 bit TraceWrapper on a 64 bit system for following scenarios:
- You need debug your app in Visual Studio directly. In this case, process launched from Visual Studio debugger runs in WOW64 mode.
- IIS is configured to run in 32 bit mode. In this case, all working processes run in WOW64 mode.
This is because in 64 bit windows, processes in WOW64 mode are 32 bit processes and can’t load 64 bit TraceWrapper.dll.
If you want to know the version of currently executing managed assembly, you can use Reflection.Assembly.
Here is code snippet which can be used to do get managed assembly version.
private string GetVersion()
You might see following error when browse your application site targeting ASP.NET 4.0 on IIS 7 or 7.5 server.
HTTP Error 500.21 – Internal Server Error
Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list
Cause & Solution
If IIS is enabled after DotNet 4 installation then ASP.NET is not registered with IIS. You will see the error if your site is targeting ASP.NET 4. To resolve this issue, run the following from elevated command line to register ASP.NET 4:
This will register asp.net with IIS. The aspnet_regiis.exe file can be found in either
- %windir%Microsoft.NETFramework64v4.0.30319 (on a 64-bit machine)
More info for ASP.NET IIS Registration Tool (Aspnet_regiis.exe) can be found at http://msdn.microsoft.com/en-us/library/k6h9cz8h.aspx
If you setup a WordPress site on a server in intranet behind a proxy, you might get following error when you search plugins and themes in admin console.
An Unexpected HTTP Error occured during the API request.
This is because WordPress does not know the proxy server to talk to external internet. To resolve this, simply enable proxy by adding following lines to wp-config.php file
Replace 192.168.110.1 and 80 with your actual proxy server and port.
If the intranet proxy requires user authentication, appending following lines.
tf.exe is Team Foundation source control command-line tool which can be used to perform source control operations without GUI interaction. Here are some common tf commands I use in my daily work. You can run command tf /? to view more or visit MSDN TF Command Line Tool Reference
Common tf commands
||Sync files under current folder
|Sync files under current folder and all sub folders
||tf get . /r
|Sync file to a given revision
||tf get <filename>;<revision>
|Display what would be synced
||tf get /preview
||tf get /all
|Force sync, will override existing files
||tf get /force
||Add new file
||tf add <filename>
||Checkout file for editing
||tf checkout <filename>
||tf delete <filename>
||Submit open files to tfs server
||Resolve file conflicts
|Resolve file with automatical merge
||tf resolve /i /auto:acceptmerge>
||Package pending change and store to tfs server
||tf shelve <shelvesetname>
||Unpackage shelve from tfs server into current workspace
||tf unshelve <shelvesetname>
||Update workspace configurations
||tf workspace <workspacename>
Common tfpt commands
tftp.exe is a command line tool that you can use to work with files and directories under version control, team projects, and work items. Some commands display a graphical user interface when run. tfpt.exe is part of Team Foundation Server Power Tools which can be downloaded here.
|Revert unchanged files
||tfpt uu /noget
|Search all modified files not in source control and add to pending change list
|Scorch – Remove all files in local workspaces but not in source control
||tfpt treeclean -delete
|Undo submitted change
|View difference of a shelve
||tfpt review /shelveset
To debug msbuild build failures, you can run following from VS command prompt to get more build log output
msbuild /v:diag <solutionname>
If you want to log messages for debug during build, you can use Message tasks. For example, use Message task inside a target
<Message Text="Project File Name = $(MSBuildProjectFile)" />
<Message Text="Project Extension = $(MSBuildProjectExtension)" />
If you are doing build in VS2010 IDE, you can follow these steps to turn on verbose building to help debug msbuild issues.
- Open Visual Studio and go into the Tools->Options menu
- Go to Projects and Solutions->Build and Run and set MSBuild project build output verbosity to Diagnostic.
- Rebuild your project and now the output will show you all the environment variables and parameters.