Solution:
Just go to server explorer, right click references and select System.XML from the .Net tab. Rebuild your project and the error should no longer be there.
Filed under: .net, Microsoft, Technical, XML | 2 Comments »
Solution:
Just go to server explorer, right click references and select System.XML from the .Net tab. Rebuild your project and the error should no longer be there.
Filed under: .net, Microsoft, Technical, XML | 2 Comments »
I was having trouble with setting a background image for an input button in IE 6. The background-image property that worked in Firefox 2.0 just did not have any effect on IE6. After a bit of googling, I realized that the background-image property will not work on IE and that we need to use the background property. Here’s a snippet that works on both browsers:
<input type=”button” class=”button” title=”Background Image” />
.button{
background: white url(’images/imagebutton.gif’) no-repeat top;
width: 150px;
height: 40px;
color:white;
}
Filed under: CSS, Technical | 6 Comments »
I was running a WinXP box and all of a sudden I started getting a “Server Unavailable” error. I know for a fact that it had to do with the ASPNET account. So here’s what I did that did not help:
1. Give ASPNET account full control over your home directory
2. Delete ASPNET account and ran aspnet_regiis -i
3. Google for the error got me to this link KB315158.
Extract from the article:
RESOLUTION
To work around this problem, use one of the following methods:
•Create a weak account that has the correct permissions, and then configure the <processModel> section of the Machine.config file to use that account.
•Set the userName attribute to SYSTEM in the <processModel> section of the Machine.config file.
•Configure the <processModel> section of the Machine.config file to use an administrator account.
I chose to proceed with option 2. I opened up Machine.Config located in
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config
And modified the following line:
FROM: <processModel autoConfig=”true”/>
TO: <processModel username=”SYSTEM”/>
I tried accessing the website and still the same error. Well, the one thing that was missing in the article is that the processModel section will only be called when IIS starts. So I did a
Start -> Run -> IISRESET
I tried accessing the website and it started working. I was a little worried about using the SYSTEM account so I went back to the machine.config, reverted the changes I made (set processmodel back to autoconfig) and restarted IIS. Well the site still works.Its crazy… I am not sure as to what happened, but If someone knows why this worked please let me know in the comments!
Filed under: .net, Asp.net, IIS, Tips | 12 Comments »
I wanted to do a case insensitive xpath lookup in my C# .Net application. There was no direct way that i could find to get the job done, but fortunately the workaround ain’t that difficult. Lets consider the following example:
<xml>
<books>
<book id=”1″ name=”Book1″ type=”fiction” />
<book id=”2″ name=”Book2″ type=”nonfiction” />
<book id=”1″ name=”Book1″ type=”FICTION” />
</books>
To request for all fiction books here is the xpath query:
“books/book[translate(@type, ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’, ‘abcdefghijklmnopqrstuvwxyz’) =’fiction’”
Filed under: C#, Microsoft, Technical, Tips, XML | Leave a Comment »
I had a table with two columns: ID and Description. The task was to display the description of all elements whose ID is a power of two. Here’s the query that let me accomplish that:
SELECT ID, Desc FROM tblBits WHERE ID > 0 AND ID & (ID-1) = 0
How does this work?
Every power of two when converted to binary has only one bit set.
For example: 4=100, 8=1000, 16=10000
And one digit less in binary looks like:
3 = 011, 7=0111, 15=01111
So an AND operation between {4,3}, {8,7}, {16,15} and so on will always yield a ‘0′
Filed under: Microsoft, SQL, SQL Server, Technical | Leave a Comment »
I was using ASP.NET 2.0 along with Ajax Extensions 1.0. I received this error ‘Sys’ is undefined error message every time I used an Ajax control. I was pulling my hair out on it and decided to give the Control Toolkit’s web.config a glance. The following lines were not available in my web.config, so i copied them over:
<httpHandlers>
<remove verb=”*” path=”*.asmx”/>
<add verb=”*” path=”*.asmx” validate=”false” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add verb=”*” path=”*_AppService.axd” validate=”false” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add verb=”GET,HEAD” path=”ScriptResource.axd” type=”System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ validate=”false”/>
</httpHandlers>
<httpModules>
<add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
</httpModules>
P.S: These lines go inside the System.Web section of your web.config file
Bingo.. the error vanished and all my controls started to function as they should
Filed under: .net, Ajax, C#, Code, Microsoft, Technical | 10 Comments »
I wanted to give WPF a try and was creating a timer application which will pop up a window once a while. But what I wanted was for the application to keep running in the tray even when its closed. The following code does NOT work in WPF for some reason:
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
Window.Visibility = !Window.Visibility;
}
In order to hide a closing window in WPF, this is what needs to be done:
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//Do some stuff here
//Hide Window
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (DispatcherOperationCallback)delegate(object o)
{
Hide();
return null;
}, null);
//Do not close application
e.Cancel = true;
}
I was using the StreamReader class to read the contents of a text file. I was under the assumption (well I know its a bad
thing) that because I am only reading the contents of the file, the file would be available for other applications to read or write. Guess what, i was wrong. The StreamReader class does maintain a lock on the file until you call the Close() method. So to not have the lock, we have to explicitly set up the sharing mode.
FileStream fs = new FileStream(@”c:\test.txt”, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
StreamReader sr = new StreamReader(fs);
txtContents.Text = sr.ReadToEnd();
sr.Close();
Filed under: .net, C#, Code, Microsoft, Technical | 2 Comments »
I had a blog server which I felt compelled to migrate to WordPress 2.5. The existing blog server can only emit the data in the BlogML format. So I set out to find an BlogML importer for WordPress 2.5. I stumbled upon Aaron’s post on importing to wordpress. So here is what needs to be done:
We are all set now. Just go to your wordpress admin page and navigate to Manage -> Import. If all is well, then you should see an entry for BlogML. Just click on the link and follow directions to import the BlogML file into your WordPress blog.
PS: Once you click on the BlogML link on the import page if you are unable to view the “Upload file and import” button then don’t worry, just open up the BlogML.php file and modify the following lines:
// Instantiate and register the importer
include_once(’import.php’);
if(function_exists(’register_importer’)) {
$blogml_import = new BlogML_Import();
register_importer(’blogml’, ‘BlogML’, (’Import posts, comments, users, and categories from a BlogML file’), array ($blogml_import, ‘dispatch’));
}
to
// Instantiate and register the importer
//include_once(’import.php’);
//if(function_exists(’register_importer’)) {
$blogml_import = new BlogML_Import();
register_importer(’blogml’, ‘BlogML’, (’Import posts, comments, users, and categories from a BlogML file’), array ($blogml_import, ‘dispatch’));
//}
Many thanks to Aaron for the plugin.
Filed under: Blog, Blog Help, BlogML, Wordpress, XML | 5 Comments »
If you are a Sysinternals fan then this one is for you. Microsoft has announced the launch of Sysinternals Live. Ever since Microsoft took over Sysinterals the one thing that i have detested is the need to search for a particular utility and scrolling to the bottom of the page just to download it. But Sysinternals live changes all of that. If you frequent Regmon, Filemon, Process Explorer, Whois, autoruns, Bginfo amongst the myriad of tools offered by Mark and his team then check this out. Just go to Start -> Run and type in
This should give you the list of all the tools at on place. This should save us some time as well as avoid the need to go to Google every time we need the link to a specific Sysinternal utility.
Filed under: Microsoft, Technical, Tools | Leave a Comment »