Archive for the ‘Visual Studio’ Category

Embed Resources into your .Net Projects

Friday, November 2nd, 2007

Worrying about file paths, locations, availability, and security of your project’s resource can be a real pain.  Fortunately, you can easily embed resources into your project’s DLL and reference them with ease from your code.  Here’s an example of how to reference an embedded XSD:

First, to embed the resource, right click on the file and choose Properties.  Next, switch the Build Action on the file to Embedded Resource. Now, when you compile your project, your resource will be compiled into the DLL with the default namespace of the project/folder location of the file within your project, e.g. if your default namespace is example.project and you put the resource into a subfolder called Resources, you would reference the file as example.project.Resources.MySchema.xsd.

To reference your embedded resource from within your code, you use reflection:

Assembly.GetExecutingAssembly().GetManifestResourceStream(“example.project.MySchema.xsd”)

which returns a Stream.  Finally, just use the XmlSchema.Read method to slurp in the stream and voila, you have your schema.

Fix FireFox SLOWdown on Vista while Debugging localhost

Sunday, October 28th, 2007

If you use FireFox to debug on Windows Vista, you most likely have noticed how ridiculously slow it is rendering localhost requests versus Internet Explorer.  No, this isn’t a conspiracy, just an issue with IPv6, FireFox, and Windows Vista.

To fix this issue, do the following:

1) Open up about:config in your FireFox browser
2) Filter or scroll down to network.dns.disableIPv6 and set this value to true
3) Restart FireFox and you should be good to go!

Format Document – The Quick HTML and Code Organizer

Tuesday, October 23rd, 2007

I have encountered a lot of bad HTML formating in my days, and one quick way to organize the HTML files via Visual Studio 2005 is to use the Format Document option from the Edit menu.

One thing about the default settings for Format Document (or Selection), is that it will wrap lines by default, which to me, can be undesirable.  To change this setting, go the Tools -> Options and then navigate the tree to Text Editor -> HTML -> Format, and uncheck the Tag Wrapping check box towards the bottom of the page.

Here too you can set any specific HTML tag format options you would like to use.  To do so, click the Tag Specific Options button in the same group box.

Intellisense for MSBuild files

Thursday, September 27th, 2007

To “enable” Intellisense for MSBuild projects ending with the extension “msbuild”:

1)      1) Add this registry key (no line break in the key):

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Editors\
{412B8852-4F21-413B-9B47-0C9751D3EBFB}\Extensions]“msbuild”=dword:00000029

2)      Create a file called “test.msbuild” and then try to open it.  Choose “Select program from list” and browse to VS2005 devenv.exe and check “Always use the selected”.  Click ok.  Once Visual Studio opens, you should have it!  (Since the XSD for MSBuild is already “known” by Visual studio.  Fyi – the file is located here:

\windows\Microsoft.NET\framework\v2.0.50727\Microsoft.Build.xsd

and

\Program Files\Microsoft Visual Studio 8\xml\Schemas\1033

there.

If you don’t like using the .msbuild extension, you can change it.  Just modify the registry key, changing “msbuild” to whatever extension you would like to use.