Friday, October 29, 2004

292.aspx

EXCEPTION_ACCESS_VIOLATION in SQL Server 2000 (SP3) on multiple CPU system

Now this is a strange one. The following stored procedure crashes the SQL worker process that is executing it:



CREATE PROCEDURE usp_UpdateDeviceEnabled
@idDettaglio int,
@sDevicelist text


AS


UPDATE CP_Valori
   set CP_Valori.sCPValore = @sDevicelist
   FROM         
      Colonne_Personalizzate INNER JOIN  CP_Valori ON Colonne_Personalizzate.idColonna = CP_Valori.idColonna INNER JOIN Dettaglio ON CP_Valori.idDettaglio = Dettaglio.idDettaglio
   WHERE    
     (CP_Valori.idDettaglio = @idDettaglio) AND (Colonne_Personalizzate.sType = 'CMB_DEVICE')


 


It bombs with the following errors:



Event Type: Error
Event Category: (2)
Event ID: 17052
Description:
Error: 0, Severity: 19, State: 0
SqlDumpExceptionHandler: Process 59 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.


Event Type: Error
Event Source: MSSQL$DB
Event Category: (2)
Event ID: 17052
Error: 0, Severity: 19, State: 0
language_exec: Process 59 generated an access violation. SQL Server is terminating this process.


It works on a single CPU system (Win2k3) but bombs on all multiple CPUs systems we tried it on (Win2k, Win2k3).  Tired most tricks in the book like recompiling the stored, dbcc, recreating the db on another machine etc without luck.


Most of the EXCEPTION_ACCESS_VIOLATION hits on Google refer to text fields, so we changed



@sDevicelist text


to



@sDevicelist varchar(8000)


And, believe it or not, the stored procedure doesn't bomb anymore.


It explains why we could not reproduce the problem by running the query in query analyzer, as it doesn't support local variables of type text. But it does not explain why it bombs in the first place. Suggestions?

Wednesday, October 27, 2004

281.aspx

The Return of Caller ID and other alternatives

Microsoft's original Caller ID for e-mail wasn't approved so they have merged their proposal with the Sender Policy Framework (SPF) written by Meng Weng Wong and Mark Lentczner. Have a look at the Sender ID Framework Executive Overview for a quick intro to what the Sender ID is.


My thoughts on it? SPAM sucks and there must be a way to fight it. Sender ID may be a step in the right direction, as it makes it easier to detect spam by automatic systems, but it does not prevent spam from being sent. It would be a lot better to kill the spam before it even reaches the internet. These days a lot of spam is sent by trojans and virus infected PCs with fast internet connections. There is, as far as I can see, no reason why any person or small company with a consumer broadband connection needs to send more than 1 mail every minute. Large companies are a different story but they don't have a consumer internet connection.


Internet Service Providers could block all outgoing traffic on port 25 and force clients to use their SMTP server with authentication to send mails. Mail clients are getting more secure so trojans/viruses don't use OLE Automation to send mails anymore but rely on their own spam sending SMTP client. SMTP authentication would fix the problem as they can't send mail directly to the internet anymore and they don't know the user name or password to use the ISPs SMTP server. Even if they magically found the username/password the damage would be limited as an infected host could only send 1 mail a minute and not several per second like they do now. Filtering is trivial as the ISP can work on a mail server level and not on a TCP/IP level.


I already use a similar setup on my LAN but I haven't gotten around to writing the outbound mail filter yet. You can reduce the chance of becoming a spam spewing bot by denying all outgoing connections to port 25 unless it is to your IPSs mail server


Other documents recently posted by Microsoft:


Sunday, October 24, 2004

275.aspx

Busy working on 3G and .NET

Wish I had more time to blog… I'm on a tight schedule working on compatibility and performance issues when delivering  contents to the latest and greatest UMTS/3G phones like SonyEricsson Z1010 and Samsung Z107 (wonder why all the latest models are all called Z something; Lack of fantasy? The End Of The English Alphabet?).


Only Coding & Music while I wait for the official release of project #100. More info after 4/11 when I should be able to say something without risking my job.

274.aspx

One the CD player: Kings of Convenience; Riot on an empty street

Bought the Riot on an empty street album by Kings of Convenience yesterday. Great music for coding sessions; easy listening and acoustic instruments.



One of the Amazon.com reviewers wrote "Okay if you are 30 something,". He must be a genius :-)

Friday, October 22, 2004

271.aspx

Visual Studio plugin to copy source code as html

A great little time saver; the CopySourceAsHtml plugin for Visual Studio makes it possible to copy html formatted source code to your blog without cutting and pasting it via Word.


Pasted via CopySourceAsHtml:




if (itWorks) 
{
Console.WriteLine("Cool Or What?");
}


Word is better from one point of view though: I can paste the code directly in the .Text edit window. With the plugin I have to go to the html source and paste the code in the correct place. OK for small posts like this but a bit of a pain in larger posts like the one on accessing the Pocket Outlook from .NET CF 1.0


Via [PowerToys]

Tuesday, October 19, 2004

264.aspx

Small, beautiful and fast: MenuetOS

Running a decent OS from a single floppy reminds of the first Linux builds I used (0.90-something). MenuetOS promises a lot more though with a full GUI as well:



MenuetOS is an Operating System for the PC written entirely in 32bit assembly language, and released under the GPL. It supports 32 bit x86 assembly programming since this allows for smaller, faster and less resource hungry applications to be created.


Menuet has no roots within unix or the posix standards, nor is it based on any particular operating system. The design goal has been to remove the extra layers between different parts of an OS, which normally complicates programming and create bugs.



Features
- Pre-emptive multitasking, multithreading, ring-3 protection
- Responsive GUI with resolutions up to 1280x1024, 16 million colours
- IDE: Editor/Macro Assembler for building kernel and applications
- TCP/IP stack with Loopback, PPP & Ethernet drivers
- Network applications include ftp/http/mp3/smtp servers,
- irc, http, nntp and tftp clients
- Free-form, skinnable application windows
- Hard real-time data fetch
- Fits uncompressed on a single floppy!


 

259.aspx

Apache and IIS security

Michael Howard, author of  Writing Secure Code  (2nd edition), compares IIS6 and Apache security stats


IIS 6 has been rock solid on the production systems where I use it and I have had no security problems. Got infected by Code Red on my Win2k dev machine a loooong time ago before I learned, the hard way, to harden my machines.

Monday, October 18, 2004

255.aspx

C# Edit & Continue support in Visual Studio 2005


It's official: Visual Studio 2005 will support Edit & Continue for C# What a great news on a Monday morning!



One of the top feedback requests from our customers is support for Edit & Continue (E&C) in C# in Visual Studio 2005. I am excited to announce that the C# team took your feedback to heart and has added support for E&C in Visual Studio 2005.


The Edit & Continue feature will be part of the next Visual Studio 2005 Technology Preview which will be released this week.

Thursday, October 14, 2004

249.aspx

CodeProject

CodeProject is a great resource. It has an active community with loads of sample code. I'm using the CxImage component a lot and it's a great example of the quality of the code on CodeProject.


It also has a weekly CodeProject newsletter


CodeProject member #47586  (of 1.437.688 last time I checked)

Wednesday, October 13, 2004

248.aspx

egilh project #11: Intranet Search

What: First some background info: I like to know how things work. I started picking apart broken kitchen appliances when I was a kid, trying to figure out what was wrong. I had a hard time buying spare parts though as repair centers wanted to do the job themselves to earn money. These days I check out How Stuff Works once in a while to learn something new.


It's the same interest in knowing what goes on behind the scenes that got me started programming as well. My neighbor convinced me to spend the few bucks I had earned picking strawberries during my summer vacation on a computer. I started using Lotus and WordPefect, constantly wondering how the stuff worked. I got my hands on Turbo Pascal and tought myself programing from the excellent online help an examples.


Fast Forward 10 years: AltaVista launched their search service,and I said to myself: how do they do that? So, during compiles and installations of Windows 95 I built a fully working crawler, indexer and web search server. I had limited resources but wanted good performance so I decided to use NTFS as a DB. FAT had a horrible linked list to find files but the "new" NTFS used b-trees to do very fast file name based lookups. Each page I crawled got a unique ID and was added to a fixed size record file with the title of the page, abstract, url, date etc. For each unique word in the crawled page I added the ID to a word file. Each word had it's own file in a directory system to avoid to many files in one directory. The ID of pages using the word 'Hello', for example, were saved in "\h\e\llo.dat". Pages that used Hi were stored in "\h\i.dat". One word queries were lighting fast as I just had to open a flat file with 32 bit IDs to get the list of pages containing that word. AND/OR queries were simple as well as I just had to join/intersect arrays. Then again, it didn’t have any of the fancy smancy Google relevance logic. It was a lot of fun to make and watch the progress of the crawler as it found it's way to the various internal web servers in Microsoft.


When: mid 90


Lessons learned:



  • The Microsoft web site is -huge-. I don't remember how, but my crawler ended up on the two internal mirrors of the public web site and it got "stuck" indexing the public web servers only. I can only imagine how large the site is now, 10 years later.

  • Sockets on Windows

  • Work smarter, not harder and you can accomplish incredible things

  • Parsing badly formed html pages

  • Html can be a pain to parse in C++. Long live Perl for parsing strange stuff and xpath for dealing with xml/xhtml

247.aspx

POOM sample: creating a new private task

Neither Outlook nor Pocket Outlook marks tasks as private. If you have a private PC it's not a problem but if you work with an Exchange server some companies leave your mailbox configure so -everyone- can see your "public" tasks. My tasks are private and they should stay so.


The following code sample uses the Pocket Outlook .NET Compact Framework class library to create a new task, set the due date to today, an mark it as private and display it so the user can enter subject and notes:


public enum Sensitivity


{                


      Normal = 0 ,


      Personal = 1,


      Private = 2,


      Confidential = 3


}



/// <summary>


/// Create a new task. The due date is set to Today


/// </summary>


/// <param name="sender"></param>


/// <param name="e"></param>


private void menuNew_Click(object sender, System.EventArgs e)


{


      PocketOutlook.Task task = (PocketOutlook.Task) _pocketOutlook.GetDefaultFolder(olFolderTasks).Items.Add();


      task.Sensitivity =  PocketOutlook.Sensitivity.Private;


      task.DueDate = System.DateTime.Today;


      task.Save();


      task.Display();


      //reloadTasks();             


}




 

Tuesday, October 12, 2004

240.aspx

Pocket Outlook: catching up with old tasks

I frequently have more than 20 tasks due each day. Stuff that must get done in high priority, some low priority reminders and blog notes. On the PC I use an Outlook macro but there is no macro language on the Pocket PC so I used the modified Pocket Outlook .NET CF class library to catch up with old tasks.


// In the class declaration


private PocketOutlook.Application _pocketOutlook;


...


 


// Startup code in the form Load() routine     


_pocketOutlook = new PocketOutlook.Application();                      


_pocketOutlook.Logon();


 



 


/// <summary>


/// Catch up with task that are due in the past


/// </summary>


/// <param name="sender"></param>


/// <param name="e"></param>


private void menuCatchUp_Click(object sender, System.EventArgs e)


{                


      // Get all tasks due before today


      PocketOutlook.ItemCollection tasks = _pocketOutlook.GetDefaultFolder(olFolderTasks).Items;


      PocketOutlook.ItemCollection oldTasks = tasks.Restrict("[DueDate] < \"" + System.DateTime.Today.ToString("dd/MM/yy")+ "\" and [Complete]=False");


     


      // The list auto-updates so we go a while loop always working on the first item instead of


      // using a for loop


      int updatedItems = 0;


      while (oldTasks.Count > 0)


      {


            updatedItems++;


            PocketOutlook.Task task = (PocketOutlook.Task) oldTasks.Item(1);  // 1 based                   


            task.DueDate = System.DateTime.Today.;               


            task.Save();


      }


      System.Windows.Forms.MessageBox.Show("Updated " + updatedItems + " tasks.");             


 


      // Reload the task list


     


}


 


 

239.aspx

Adding Google AdSense to a .TEXT blog

Had to look around the templates for a while but I found it in the end. Add the following in at the end of Skins\SkinName\Controls\CategoryList.ascx and insert the JavaScript script from Google. Works like a charm.


<ItemTemplate>


            <h3>Sponsored links</h3>


                  <ul>


                  <li>                         


                  PASTE SCRIPT HERE


                  </li>


                  </ul>


            </script>


</ItemTemplate>


 

Friday, October 8, 2004

234.aspx

Blog Schneier blogs

Bruce Schneier has started his own blog. I have been a faithful reader of the Crypto-gram newsletter / blog since I read the footnote in Cryptonomicon. He knows a lot about security and writes about it with a passion.


Via [Larry Osterman]

Thursday, October 7, 2004

228.aspx

egilh project #10: joke server

What: a small web based joke server. I saw all this programs popping up on the web and wanted to find out how I could implement my own. Collected some jokes I had in my inbox and saved them to a formatted text file (no xml yet). Wrote an indexer that generated a tiny lookup table so I didn't have to parse the entire file to pull out a joke. The CGI program in C pulled out a random joke each time a page was requested. Nothing fancy but it was fun to make and test.


Upgraded it later to use the predecessor to ISAPI when it was made available in a small web server that ran on Windows 95.


When: mid 90s


Lessons learned:



  • CGI is grand but ISAPI is way faster on Windows


 

Monday, October 4, 2004

223.aspx

Using the clipboard from .NET CF

I was about to implement my own clipboard classes for .NET CF when I found the Clipboard usage article.


It has complete source code that implements the two alternatives for working with the clipboard in .NET CF.


Alternative 1: use P/Invoke to call the following methods:
[DllImport("Coredll.dll")] private static extern bool OpenClipboard(IntPtr hWndNewOwner);
[DllImport("Coredll.dll")] private static extern bool CloseClipboard();
[DllImport("Coredll.dll")] private static extern bool EmptyClipboard();
[DllImport("Coredll.dll")] private static extern bool IsClipboardFormatAvailable(uint uFormat);
[DllImport("Coredll.dll")] private static extern IntPtr GetClipboardData(uint uFormat);
[DllImport("Coredll.dll")] private static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem);


Alternative 2: use the keyboard shortcuts
So far I manually work around the missing clipboard support in .NET CF by switching to the Keyboard instead of the "Block Recognizer" when I have to cut and paste. The Windows shortcuts for cut and paste works like a charm;
Ctrl + X: Cut
Ctrl + C: Copy
Ctrl + V: Paste


The textbox example adds a popup menu to a text field and simulates the user pressing keys buy using the keybd_event API.