Monday, December 26, 2011

VoIP "Can't Hear Me, Can Hear Them" Issue

Symptom:

You have (deployed) a SIP VoIP telephone set (can also be a software SIP phone) at home. Your phone rings and you can even dial out but the recipient of a call cannot hear you, though you can hear the recipient's voice.

Issue:

(1) This means that the SIP protocol is going though but the RTP protocol is not going through. This happens in a typical home WiFi "router" scenario connected to cable or DSL service.

(2) Has your phone been in your corporate office or a branch office? Sometimes, these phone are set behind an "EDGE BOX" that provides different protocols and have different codes in the firmware. 

Possible Fixes:

If your situation applies to (2) above then you need to call your IP service provider, explain to them that you have moved your phone from your office to home and requires a "Push of new config to your phone."

Below applies to everyone. In most cases the blocked UDP by your wireless router is the key! 99% of the case this is it.
 
Most people use a wireless router at home. However this will cause an issue as most of them prohibit UDP protocols to go through via their built-in firewall. Thus it is time for you to learn to open up firewall settings on your router.

If you cannot make a call at all or if you cannot receive any calls at all: Check UDP 5060-5063 ports.

If the sound is an issue then try opening UDP Port 16384 - 16482, or 10000 - 20000. This depends on the phone implementation.

Note: If you are an Astound customer, try connecting the phone directly to the DMZ port provided by Astound.








Sunday, December 11, 2011

Mac Lion Windows Remote Desktop Freezes - Alternate Solution

Symptom

When you "log out" from a Remote Desktop session using the Windows Remote Desktop client, it either freezes or hangs. If it is in full-screen mode, it would not even allow you to open the Apple Menu to force quit the application.

As of December 2011, there is no updated version of RDP Client from Microsoft. If you beg to differ on this, please let me know since I am no longer using the MS RDP.

Workaround/Alternate Solution


Try using CoRD from SourceForge. It actually provides better user experience than the RDP client from Microsoft. It works on all recent versions of MacOS X including the Tiger version. I especially like the fact that the user/password management is built in to the software. (for me the Keychain with MS DRP goes out of Sync very quickly if you are connecting to multiple hosts frequently, usually ending up typing user and password every time.)

Update (5/10/2012): CoRD is not that super-stable either on my iMac with Lion, but it never totally hangs. CoRD tends to crash hard when losing a connection that was running, for example, when I close the VPN connection while the RDP is still connected, it is guaranteed to crash right now.







Monday, December 05, 2011

LINQ To XML Tips


Use XElement instead of XDocument in LINQ to XML

I misunderstood that it is usually the XElement that is all I needed and not XDocument to work with LINQ to XML.

XElement has just about everything you need and also LINQ works mainly with XElement.

For example, the following code can locate all the "top level" nodes titled page. Within each of the element you can actually find the element titled "regex" no matter how deeply inside that elemenet's tree. This is because I am grabbing all descendant level nodes.


       public void Test(XElement FinderSpec)
        {

            var pages = from f in FinderSpec.Descendants()
                    where f.Name == "page"
                    select f;

            foreach (var i in pages)
            {
                var reg = from tre in i.Descendants()
                          where tre.Name == "regex"
                          select tre;

                foreach (var re in reg)
                {
                    var rs = re.Value;
                }
            }

        }


The XElement class also has handy Load and Save from file as well.

var el = Xelement.Load("test.xml");
el.Save("test2.xml");













Sunday, November 20, 2011

Taking Advantage of the Microsoft XPS "Virtual Printer" Even on Macs and iPADs

Symptom:

I was using an application and the result of which is only output via a Print interface. To make the matter worse, this was on a remote site so I could not print to my printer either. To make it even worse, I don't feel like adding any PDF printing driver to this machine as it belonged to a customer.

Fix:

I have been aware that Microsoft XPS driver is installed on just about any modern Microsoft OS machines, and it is even often annoying that it comes up as a default driver to my mothers-in-law PC and she cannot print to actual paper.

As it turns out, you can consider this XPS as the pre-installed "PDF" driver that works on Windows. And since .NET Framework 3.0 a "free" viewer comes "pre-installed"; all you need to do is to activate it! Like just about anything Microsoft (Apple) does, XPS is designed to kill  other company's product, in this case the PDF.

Whether XPS is superior to PDF or not, I don't care, I am not in printing business, but, this means that we can print at most computers without any physical printer, and take or email the XPS file back home and print at your leisure (or just view them to save the tree) or re-print them in PDF once you get it back on a PDF enabled computer.

To "install" or actually "activate" the XPS viewer, see this MS article. What is XPS Viwer

Other platform users do not need to dismay. You can try uploading the XPS file to your Google Docs account and view it online!

Note that the article is a bit obsolete, in systems with .NET framework 3.5 (probably) or later the XPS viewer enable is not within the .NET Framework feature but are listed in the top level list.


SQL Server 2008: Cannot Detach The Database

Symptom:

You have a dead file for a database that was active. For example, you have lost a disk drive or if you have lost file MDF file. Now you try to detach it from the SQL Server Management Studio, it won't let you do it.

Fix:

Try manually firing the query then

use master
drop database

The key above is that you are going to the master and not any other databases.


Saturday, November 19, 2011

Tortoise Git Tips: How To Use It Behind an HTTP Proxy

Problem:

You want to connect to the Git Server via HTTPS (say GitHub.com), but you are behind a proxy. You know the proxy information.

Fix:

Issue the following Git command from the Git Bash. In this example my proxy is at DaProxy... port 8123

config --global http.proxy http://DaProxy.myhospital.edu:8123




Monday, November 14, 2011

Where is The DLL for System.Windows.Media.Imaging Namespace?

Symptom:

You wanted to use classes from System.Windows.Media.Imaging Namespace, but there is no such class when you try to Add Reference from your Visual Studio.

Fix:

Add PresentationCore, which you should find under the .NET tab of Add Reference dialog box.


Monday, November 07, 2011

Bluetooth and/or WiFi Abruptly and Intermittently Goes Offline on Windows 7 Laptops

Recently I had a symptom in which Bluetooth and WiFi stops working temporarily. This is a problem for me because I often use RDP to connect to my laptop and it drops connections. Interestingly in my case, each time this happens the CPU fans go faster for a bit, so I suspected that this has something to do with the power.

As it turns out, both Bluetooth and WiFi network devices can shut itself down by default due to automatic power management controls.

This behavior can be disabled from the Device Manager (just type these words in at the Start menu) and go to each Bluetooth Radio and WiFi device properties. You will find the Power Management tab where you can configure this.

I just did it so I will update this will or will not work in a longer run.


Saturday, November 05, 2011

Windows SC.EXE Command Gotcha

Symptom:

You wanted to create/install a service using the SC.EXE command on Windows 2008 (XP as well) but it does not seem to work. It come back with the help message suggesting that you have had some errors.

sc create MyService binpath="c:\MyService\MyService.exe" type="own" start="auto"


This WILL result in errors and it won't tell you how you have errored.

Fix:

Fix your brains that it is not Unix that you are dealing with, since we cannot fix someone who designed it at Microsoft.


sc create MyService binpath= "c:\MyService\MyService.exe" type= "own" start= "auto"

Do you see the difference between the two?

There is a blank after each= sign.  Not an example of world-class coding.










Tuesday, November 01, 2011

How To Escape Textile Formatting

Problem

You want to write express on the text things like %TEMP%\My Directory\ on a Textile format (such as on Basecamp Writeboard) but The % character goes away.

Solution

Use the ==

==%Temp%== and the % will now appear in the text.


Sunday, August 28, 2011

MS ReadyBoost Implementation Tips - Do Not Bother

Recently I got a small Lenovo V470 IdeaPad and have been playing with it with Windows 7 Pro 64 bit version. Along with it I found out about the ReadyBoost technology they have added into the OS since Vista.

Initially ReadyBoost does not seem to be doing anything. In fact, initially it even slows you down as it builds the cache, and actually does not make Booting faster by much. What it makes faster is applications to launch faster, especially when more applications are running consuming more RAMs and disks are working hard to service the applications.

I ran into a couple of snags thought I resolved it so here is a quick summary of how you can implement Readyboost on your laptops.
  • As far as I know this works only with the Built-In SD card slot which is wired into the PCI bus and does not go through the USB.
  • Get at least a 16 GB SD card with at least Category 10 capability. I had Category 4 and that failed the qualification step to activate ReadyBoost.
  • Before doing anything, Format the card with NTSF and not FAT32. The reason for this is that for FAT32, the maximum file size will be limited to 4 GB.  For your laptop applications, you would want as much Readyboost cache space as possible. Typically this is 3 times or more of the RAM. Given most PCs are sold with 4 GB RAM. Having a 16 GB SD would be sufficient.
  • Don't use Readyboost on your laptop unless it is connected to the AC power (this makes ReadyBoot almost useless while in battery operation.) As soon as you boot, it starts to cache data and also re-encrypts data. This means this activity occurs during every reboot and every wake-up from hibernation. NOTE: If you run into this situation while in battery operation, you can pull the card out without causing a problem. Re-encryption cannot be turned off on external devices so there is no easy way to turn this off.
  • If you have lots of RAM, you may not notice the difference.
Hope this helps.

Sunday, August 21, 2011

MSMQ, You Get "Invalid queue path name" Exception When Opening a Remote Private Queue

Example Symptom:
  • You have a remote computer named XYZZY
  • Inside it is a private queue named MyQueue
  • You have written the MSMQ code in C# (or .NET)
  • When accessing locally within XYZZY, you can use .\private$\MyQueue it works.
  • When trying to get to the queue using "XYZZY\private$\MyQueue from another computer even on the same subnet and no firewall enabled, you now get an MSMQ exception stating "Invalid Queue Path Name"
Try This:

Instead of

XYZZY\private$\MyQueue

Try this way.

FormatName:DIRECT=OS:XYZZY\private$\MyQueue

Note, spell FormatName exactly how it is. It is the only part that is case sensitive!

--
This was tested on Windows Server 2008 R2 with .NET 3.5

Tuesday, August 02, 2011

Tortoise Git Annoyance Fixes and Tips Collection

I am collecting some quick fixes that I had to do to make this work the way I want it. I am using Windows 7 64-bits these days. If you are encountering other annoyances or want to share your fixes, please feel free to ask or comment on this article.

Annoyance 1: Cannot Delete A Folder, Folder in Use

This is because tgitcache.exe is running and not releasing the folder. You can temporarily kill this program from the task manager and then you can delete the folder.

Annoyance 2: The Icon Overlay on Folders are Gone

  • If the overlay icons are showing on certain drives then it is just the setup on the Tortoise Git. Just open the settings and look under Icon Overlays section. It is likely Network or Removable Drives are not checked.
  • If that is not the case then your computer has gone over the 11 icon limit as you may likely have installed DropBox or JungleDisk or such things that take up icons. If you are brave enough and take your responsibility then here is where the icons are referenced.

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers
    and then remove anything you don't need above and beyond 11 total that's allowed
Want to use the Git behind an HTTP proxy? Read this article.

Friday, July 29, 2011

How To Use Your DropBox.COM Folder As a Git Repository with Tortoise Git

Update: If you have lost your Tortoise Git overlay icons, you need to do some registry work. See the bottom of this article.

You probably came to this article because you are new to the Git Revision Control System and want to know where to store the "source control database" somewhere other than your own computer.

In my specific situation, I develop software under the Windows OS and I may have some side-project such as some research I am doing outside of my work.

GitHub.com is great, and I use it for my business but in order to get your own private GiT repository, you have to pay. They only allows you to let you have a repository if it is open to the public. But in my case, I use Git not just for software source code but many other types of files, for example, my next epic surf novel.

The main problem for me is that I would like to maintain my small repositories without a need to have an elaborate GiT server. Fortunately a GiT repository server can be nothing more than a file system that's accessible from your computer, and even better there are many "cloud disk" services around, many of them are free. The Dropbox.com based cloud disk is very convenient because it maintains the local cache, so the interaction with GiT is very fast. You just need to remember to allow it the time to synchronize the data.

Before moving forward with my example, I assume that you have installed the Windows Git and Tortoise Git on your Windows machine. I also assume that you have used Git for other stuff, for example at your work, so you are generally familiar with synchronizing your own Git repository against the server.

So here are some very straight forward steps to do.

  1. On your DropBox, create a folder which has the name of your repository. For now I will call it MyRepo
  2. From your explorer go inside MyRepo
  3. Right click and select "Git create repository here..."
  4. A dialog box will appear with a box that says "Make it bare." You need to click that check box and OK.
  5. On  any other local disk, I assume you already have your project Git that you want to synchronize.
  6. Go your local project Git folder.
  7. Right click on the folder from the Explorer and select Tortoise Git, and select Settings submenu
  8. On the dialog box navigate down to the Git node and select the Remote sub node.
  9. You are likely to have the "origin" as the remote repository, but you may have others. Select whichever one you would like to connect it to the one on the Dropbox.
  10. On the URL box, type in the path on the dropbox containing the bare bone repo you have just created. For example, C:\Users\Manabu\Dropbox\MyRepo
Now you can synchronize between your repo and the one on the Dropbox.

Fixing the Lost Overlay Icons

Go to http://www.sitepoint.com/missing-tortoisesvn-file-status-overlay-icons/ for more information. But the key for this is to go to


HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers


and then remove anything you don't need above and beyond 11 total that's allowed.






Saturday, July 23, 2011

Do and Don’ts of Email


While I am on the email topic from my previous post, I would like to pass on some of the things that made my email in work more effective. You may want to read some of my tips.

Consider Your Subject Line is Being Like a Tweet

Pack in as much useful information in the Subject line. I consider the subject line the Tweet area to contain almost the “body” of the message. This works because most people actually don’t read all email messages. They look at the subject line list and decide whether they will read the message or not.

Start Your Subject Line with the Name of Your Recipient

Again, compare these lines of subjects

1.     “Tonight’s Dinner Plan”
2.     “Want Join us for a dinner?”
3.     “John Let’s Have a Dinner at French Landry at 6”

Which do you think is most effective? To me, it is the third one. If you read the subject line #3, you almost don’t need to read the body of the email. And I know you will click the email to read on.

Start Your Subject Line with a Verb

Your email will be more effective if you start your subject line more in the “Call for Action” style.

Consider the following examples,

1.     “Blood Donation Drive This Afternoon”
2.     “Donate Your Blood This Afternoon!”

Do Not Send Additional Messages in a Quick Succession

My experience is that if you do that the recipients will only read either the first or the last message and they ignore the rest.

Carefully Time When To Send a Message

This is a bit tricky, but you need to know when your recipient will read your email message.  Most people have their email client set so that the most recent one would appear on top and messages are downloaded automatically. They usually scan only the top 10-20 lines of subject lines on their email clients. So if your message does not make it in that top 10 at the time they are reading, then you might as well consider the message lost.

Another strategy is actually just save it in your draft folder, phone call the recipient and then during the conversation mention to the person you have just send an email.

Typical times people read messages include;

The first thing in the morning
During or just after lunch
Just after dinner

You may want to start tracking the most effective time with respect to your important recipients.

Limit The Message Body Size to One Screen

People are busy (even if they really are not) they can only devote about 1 min of their time to read a message. If you wrote a message that do not fit in one screen then they tend stop reading it, moving on to the next one and never come back to your message.

Organize the Email For The Recipient

You have been frustrated with people who repeatedly ask you to send the same email message over and over again. It is not entirely the recipient’s fault; it is that the email is difficult to manage. Over time you will learn who would be asking for repeats, and in that case, make a CC copy of it on your end, put the copy in a folder with the recipient’s name on it. Then you can quickly re-send.

Use The Phone and Voicemail

If you are dealing with some emotional stuff such as one of you being frustrated, angry or extremely happy etc., then call the person up, or at least use the voicemail to leave your live message. Unless you are a NY Times Best Seller author, it is much easier to convey your emotions via voice. Talk to the person live!


Thursday, July 21, 2011

So What’s So Wrong About Email?


Everyone uses email, even if we asked them not to. I ask people to write issues into our issue tracking system. I ask people not to do attachments, instead upload them to our Google Docs and send links in the email to the document, even then people continue to attach documents, and when it comes to dealing with people outside of our organization, they don’t want to log into Basecamp account we provided, they claim they often cannot see Docs shared on the Google Docs…  Some people in my company think I am the search engine and send emails to me essentially the query to our KB or to the Google.

So what’s wrong with all these? Why can’t they use email for all of the above? It is super convenient to write about a product issue and send an email to someone whom you think can handle. Attachments are one of the best file transfer protocol there is, and I can push files to just about anyone without thinking about FTP or user accounts and passwords.

I am starting to think, can we get rid of the web, and we only use the email? It is an extreme thinking but can such a technology possible?

How would I go about to make this happen in a more realistic way? I think that the future email engines would contain a search engine front-end, a lot more statistics driven choice of automated answers, intelligent filters. This sounds awfully a lot like how Gmail works, for example, and I think they are doing a great job.

Email as the Search Engine:

I would like the search engine to already scan the KB or other places I designate based on the content I received and also the prior usage or response pattern, and suggests  possible responses I may have already written. I often get, “send me the server specifications PDF” email several times a quarter from the same person. I would like to tell the email system, next time this happens, just auto generate a reply. I then do not have to repeat myself.

I am experimenting with this using the “canned” response on Gmail but that’s not very smart yet, and it fires unnecessary responses.

Email as a File Version Control System:

If the email works a bit more like GiT and automatically aggregate the versions of different attachments that come by, and when I look for the attachments, it can give me a list of all versions, this will solve the problem of versions in attachments. This will also bring down the size of the in-box as duplicate files would be normalized.

Email as an Issue Tracking System

Gmail does this fairly well now, perhaps if I tag an email as an issue to track, then all of the related email messages will be visible by the team that I designate as a separate in-box where other people can respond, and workflow tag such as In Progress, Solved are also easy to put in. Assigning an issue is a snap then, I just forward the email to the person. 

Email as a Knowledgebase

May be I can tag some email as a knowledge and the next time I am writing on some topic, dynamic search would be performed to either suggest a response that I already wrote, or other similar email messages I have written in the past.

Most or all of the above can become possible without changing the existing email infrastructure. They are about how email servers are implemented, so it will not break the rest of the world, we do not have to change the behaviors of any of the people I am dealing with now.


Monday, July 18, 2011

DotNetNuke 5 Module Development Tips with Visual Studio 2010

I am jotting down some things I need to remember to know when starting a new C# DotNetNuke module development using the Starter Kit, most of the steps are described elsewhere, notably HERE, but sometimes they contain  wrong information in the original text that you need to dig through the user comments to find out the solution. Also there are a few key things I need to remember to do every time.

Local IIS is a Must for a Newbee DNN Module Developer

Install the base DNN in the local IIS and get that going completely first. It will complicate less for module development as it will need to look up images and other resources in the directory structure.


Where To Store The Project?

The best place seems to be within the DesktopModules folder, create a project directly in there. Then all the references are good to go. By the way, target your project to .NET 3.5

Be sure to uncheck Create Solution Folder box when creating a project in this manner.


What To Type into The Assembly Name and Default Namespace?
  • Type in the same info on both field by replacing YourCompany in the Assembly Name part with what you do, and then copy and paste that to the Default Namespace. This is for C#. I don't know VB at all so I will leave that up to you for VB.
  • Do not do a Globally Replace of YourCompany to whatever. See below!

Do Not Globally Replace YourCompany With Your Real Company


You will get the following type of error message from Edit....ascx.deginer.cs  if you immediately try to compile the project.

DotNetNuke Error 11 'System.Web.UI.UserControl' does not contain a definition for 'Text'

The reason why this happened was that global::DotNetNuke.UI. classes was inadvertently changed by the Visual Studio to global::System.Web.UI

How To Replace YourCompany


Note that order in which this is done is very important. Do not do these in out of sequence.

  1. Make a backup copy of the module project folder so that if you mess these steps, you can get them back.
  2. Open any of the classes in the control. And on the Namespace, right click over YourCompany and use the Refractor menu to change this to whatever you like.
  3. Open the Manifiest file (the one that ends with .dnn). On this one Replace YourCompany. with empty string. This fixes the install folder name from YourCompany.YourModule (make sure that the path does match with how you created your module root directory in the DesktopModules folder.
  4. Save everything.
  5. Make a backup copy of this folder again.
  6. You can now Quick Replace the rest of the files containing YourCompany (for example SQL Provider files). Use the Quick Replace at the Solution level.

Configure the Project's IIS

Next Configure the Project to Use the Local IIS Server so that images, controls and other resources in your development environment. Otherwise, your design surface will have errors. Also if any of the controls on the design surface errors out with a COM error, that means you probably did not follow my previous steps to refactor the classes properly which swapped the controls to the system default ones (not DotNetNuke.UI.Control ones), and ended up globally replacing YourCompany in the classes. You need to start over the project and follow the steps.
  1. Open the project property
  2. Select the Web tab on the left.
  3. Select "Use Local IIS Server"
  4. In the project URL, point it to the URL of your project within the DesktopModules folder. For example, http://localhost/DNN/DesktopModules/MT3 would be that I have the module project named MT3, and I have installed the DNN root at localhost/DNN
  5. Click Override application URL and type in the base URL for the DNN, for example, on my machine it is http://localhost/DNN
  6. This will also create web.config files in the folder which will interfere with the module loading. Rename it to xweb.config just in case you need it in the future.
Debugging

If everything is set right and the DNN itself is a debug version then you can attach to the IIS process w3wp.exe locally and you should be able to set a breakpoint in the project. I will write more as I find out how to do this a bit better without needing to rebuild the DNN from the source.


Sunday, July 10, 2011

GoToMeeting Mac - Microphone Level Adjustment Annoying You?

Symptom:

Every time I start GoToMeeting on my Mac, the microphone level adjusts to a very low level, and you'd need to open the System Preferences to re-adjust this level. You would want to get a single click solution to fix this issue.

Solution:

Use the Automator and create an level adjust applet. It is quite easy to do.

  • On the spotlight search on top right of your finder, type in Automator to locate it.
  • Click on the Automator to launch it.
  • Choose Application (and begin creating an application)
  • Select Utilities from the Libraries
  • Select Adjust Computer Volume
  • Adjust the Input Volume slider to the level you like.
  • Save the Application it creates.
  • Put it on the desktop or somewere you can readily click it.

Monday, June 13, 2011

Emacs csharp (C#) Mode Installation and Automatic Enable with Auto Hook on Windows

I like the editor in Visual Studio a lot.  But when it comes to do some repetitious editing, for example, writing code to insert or update database fields based on some pattern, it is a lot easier to do cut-paste-search-replace with Emacs than the GUI based editor by recording some macros.

So I do often use Emacs. And now we have the csharp mode available, the environment is quite nice.

I am not an Elsip hacker so by the time I need to do something more internal with Emacs, I have usually forgotten what I did the last time. So in order to save my own time in the future, for example, to duplicate what I have done on my home PC with another one somewhere, this article will help me do this. Perhaps you also may want to do the same thing.
  • Be sure that your emacs is installed at your C:\Program Files\ directory, for example, C:\Program Files\emacs.23.2 Unless you know a whole lot more about Emacs (in which case you should not be reading this), it is not correct to install it anywhere else, because the load-path really only points to that directory. Please do note, that even this is a 32-bit app, you still want to put the program in C:\Program Files and not in the X86 directory.
  • First, download the csharp mode Lisp code. You can Google for it as to where. But I got one from the Emacs Wiki under csharp-mode.el  Clicking this link will give you the content of the Elisp, so I would copy this into a suitable text editor (for some reasons, I tend to use Notepad for this sort of thing.) then Save As csharp-mode.el
  • Copy csharp-mode.el to site-lisp directory in your emacs installation. If the directory does not exist, I'd say it's OK to make one there. (For example, C:\Program Files\emacs-23.2\site-lisp).
  • Next, go to your Windows user home directory (at very top, above Documents), then create a .emacs file. The easiest way to do this by far is to create one from Emacs. Notepad does not allow creating files that start with a period. Just Control-X F and type in ~/.emacs   NOTE: On Windows 7, your home directory for .emacs is usually c:\Users\/AppData\Roaming\  If you used emacs to edit this, emacs will know this.
  • Now cut and paste the following lines of Elisp. I have added a bonus hook to enable HTML editing mode for aspx and ascx below. Save the file, re-launch emacs and you are good to go.
(autoload 'csharp-mode "csharp-mode" "C# Mode" t)
(setq auto-mode-alist (append '(("\\.cs$" . csharp-mode))
auto-mode-alist))
(setq auto-mode-alist (append '(("\\.aspx$" . html-mode))
auto-mode-alist))
(setq auto-mode-alist (append '(("\\.ascx$" . html-mode))
auto-mode-alist))

Sunday, June 12, 2011

Building DotNetNuke 5.6.2 Source with Visual Studio 2010 Professional

This weekend, I have finally decided to download the DotNetNuke Community Edition source code and decided to build it with Visual Studio 2010 Professional Edition.

It took several trial and errors so I am going to write down what has worked, mainly so that the next time I will remember how I did it and worked.
  • If you are on Windows 7 (and should be), be sure to permanently enable the Visual Studio to run as Administrator. This will save a lot of time re-running it as DNN projects install and configure IIS 7 and that requires an elevated privilege. If I tell you to just open the  privilege setting is in the Property of the Shortcut, then you know how to set this up even if you have not done that before. Still not making sense? See this Technet KB Article
  • Make sure you have a working SMTP server. You will most likely need to setup an email address then a password which is usually needed for modern SMTP servers.
  • Unzip it to Some Simple Directory, like C:\DNN  You will be editing the solution file pointing to this new location. When the solution loads, it will create a Virtual Dir on IIS 7 (that means you have to install IIS 7 beforehand
  • Add Web Management Tools -> IIS 6 Management Compatibility -> IIS Management Console AND IIS Metabase and IIS 6 configuration compatibility
  • Under the World Wide Web Services -> Application Development Features, ASP.NET should be added.
  • Make a first backup copy of the Unzipped version to somewhere safe. You will likely mess up the next step and will likely accidentally launch the solution (.sln) file before the required hand-edit,and corrupt it beyond repair.
  • Don't Launch the Solution File yet. You need to hand-edit it first.
    • Text Edit the Web Root name (the line that has http: in it) to something short and sweet like http://localhost/dnn  
    • To make sure you don't do an accidental start of the project, edit the solution file using Notepad by starting the Notepad then do the File->Open.
    • Go and find any places that has E:\blah\blah on it, and make the change that correspond to where you put the unzipped directory.
    • But don't change where it says VirtualPath that will break the loading of the web project.
    • If none of the above is making any sense to you, then definitely make a backup of the solution file before you do anything  and ask someone who might know.
  • On IIS if you don't have one create an Application Pool to .NET 4.0 Framework
  • Set the Application Pool User to Network Service. This can be done in the Advanced property menu. It is a lot simpler for me to use the Network Service than something else especially on a local develop machine. By default the Application Pool it uses is the Default Application Pool.
  • Give Full R/W permission to Network Service for the entire DNN tree.
  • Backup the DNN Directory to Another Directory. If you (are likely to) fail after the following steps any work you have done won't go to waste.
  • Now you can launch the Solution, and let it build. This should go smoothly.
  • Create a Database
  • Create a login account for the database on the SQL (Express) server and assign the dbo capability to the account. 
  • Copy development.config to web.config
  • Set the web project as the startup (this should be indicated as the URL you specified when you edited the solution file.)
  • Go to IIS Admin and make sure that the Virtual Directory is pointing at "Website" directory within  the  DNN development directory tree and assign the Application Pool that is running the .NET Framework 4.0
  • Then start the the debug session of the web project.
  • If everything compiles fine and the web site runs OK, then exit the Visual Studio, make a backup copy of the entire directory. In fact, you should always do this before a major change to your project, such as adding or removing a project. It is also a big time saver to back up your DNN database prior to making a major change to the DNN configuration, such as adding or removing a module.
Failure Recovery

The initial debug run goes exactly like installing a brand new site. If the startup jams during SQL script part, then without a hesitation, drop the database and create a fresh one. There will be some unfinished stored procedure or other stuff dangling and it won't install the second time.

Teralic Installation Issues during setup: I ignored this issue and the site is working fine. I will report if there will be issues.


Tuesday, April 12, 2011

LINQ To SQL DatabaseContext Insertion Memory Bloat & Clearing the Cache

Symptom:

You have inserted a huge number of records using the InsertOnSubmit(row) call, and you have ran out of memory in your .NET program using LINQ TO SQL technique.

Cause

The DatabaseContext caches all previously inserted rows.

Solution

There are many articles on the net using the Reflection locate the internal ClearCache then call it. This is not the intended use of the DatabaseContext object. It is a light-weight object and thus, you should simply dispose a object and create a new one. In my situation after a few thousand consecutive insertions, I dispose (i.e., new the object into the variable previously held the old context object.) This is also significantly more efficient way of clearing the cache held.

Friday, February 11, 2011

Installing Drupal 7.0 Experience on Joyent SmartMachine

This is a quick note to myself regarding the installation of Drupal 7 on Joyent SmartMachine

  • Creating the database and user is done from the Webmin->Servers->MySQL_Database_Server.  Be sure that the you give the select, create, drop and insert permission to the mySQL user that you will give to Drupal
  • SSH Login as the admin user then sudo bash
  • The content of the drupal tar goes into /home//web/public so in other words in that directory, you should have install.php
  • PDO may be disabled (it was in my case). To enable it, edit /opt/local/etc/php.ini and uncomment pdo.so and pdo_mysel.so uncomment to mean to remove the semicolon.
  • From the shell reboot the machine by tying in "reboot"  This will activate the PDO (there are other ways to do this, this is one of the quick ways to do it.)

Sunday, February 06, 2011

Annoyed by: System.Xml: The node to be inserted is from a different document context?

 Symptom:

You try to copy one or more XML Nodes (usually elements though) from one XMLDocument and another, and you get the following error:


System.Xml: The node to be inserted is from a different document context.

My Fix, Hint:

(Note from 1/21/2012: Try using the XDocument class and LINQtoXML, it's much easier to deal with!)

There is an official way to fix this using clone, import and InsertBefore or After. But that's too difficult to figure out, in my case I still get the above mentioned exceptions. I often do not know which node to insert (you are supposed to find the parent node then insert) or afraid to insert something at a wrong node level.

Rather than wasting a whole lot of time, I do this entirely in text using StringBuilder and such. You will find the following methods very handy.

XmlNode.OuterXML

  • This contains the Text representation of XML including the node itself and all of the children.

XmlNode.InnerXML

  • This contains the Text representation of XML node of all its children.

You know that you can build up a string using StringBuilder.Append(string) you can form the basis for the new XML document which some of the node data copied from another XML document WITHOUT having any issues with copies being prohibited between two documents.

As an added bonus, you can see exactly the new XML document being formed since it is in the string form.

Once you form the destination XML, there is a handy function LoadXML(string), and you are back to have the new XMLDocument. There absolutely is no need to create a StringReader or stream of any kind.



XmlDocument xd = new XmlDocument();
var sx = sDoc.ToString();
xd.LoadXml(sx);

Hope I gave you enough hint here, but if you need a more complete coding example, please post a comment and next time I come back here I will write one up for you.