Monday, June 11, 2012

IE 9 Crashes on MSN

Symptom:

You open IE 9 and go to http://msn.com   IE 9 crashes with the "Internet Explorer Stopped Working" dialog box.

Root Cause:

I do not know. I am suspecting that it is the Flash player.

Fix:


  • Try manually re-installing the latest version of Adobe Flash player. In my case this has corrected the issue.
  • If going to MSN is only your goal, MSN works perfectly fine with Firefox or any other non-Microsoft web browsers.
  • If you have to use the IE for testing and debugging and such, you can go to Internet Options on the control panel and make the home page to Blank.






Saturday, June 09, 2012

VS 2010 Web Debug Fails To Start Due to "Invalid file name for file monitoring"

Symptom:

You try to launch your ASP.NET web application from Microsoft Visual Studio (2010) and you get the following error (you swear it was working an hour ago.) Note that the file name mentioned does not really matter. The symptom is that you cannot launch a web page in debug mode.

Invalid file name for file monitoring: 'C:\Blah\Whatever\App_LocalResources'. Common reasons for failure include:

Cause:

The root cause is completely understood, but it has something to do with catching all un-handled CLR exceptions in the debug menu.

My Fix (May Not Work With You):


  • Go to Debug->Exceptions and un-check all un-handled exception checking.
  • Try to launch the debug session again. This time, it worked for me.
  • Go to Debug menu and then clear all break-points. This time, I can re-enable un-handled CLI exceptions and back to be able to launch and debug the app.
  • If above does not work, clear the .NET temp files for the framework version you are using. For example,

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files




Tuesday, June 05, 2012

Windows 7 Desktop Freezes Up But Start Menu OK

Symptom:

For "no obvious strange reasons" (actually for a good reason, see the cause below) the Windows 7 desktop suddenly freezes. For example, you cannot "right mouse click" on any items on the desktop. But Start Menu works just fine.

Cause:

This turns out to be iexplorer.exe process not completely closing down. You can find out if this is actually your case by going to the task manager and manually killing the iexplore.exe (may have *32 next to it if you are running a Windows 7 64-bit version)

Fix:

This may be due to the IE configuration or plug-ins being messed up. You can optionally reset the IE settings using this information.

IE is totally a fine browser but you can use Firefox as your default browser and you can avoid this problem in exchange for possibly other problems.

Note:

Around June or July of 2012, my Google Chrome is starting to exhibit similar behavior. I am investigating but usual "clean everything" seems to be working.



Saturday, June 02, 2012

Visual Studio 2012 Show Stopper Collections

Just installed the VS2012 RC a few days ago. I am tallying any show stoppers.

SQL CLR "Corruption"


Symptom:

I had an MSMQ triggering CLR in SQL Server 2012 Express. It seems that after installation of VS2012 the assembly stopped working.

When the assembly was called from a stored procedure, I got a message somewhat like this:

Server: Msg 6522, Level 16, State 2, Line 1
A .NET Framework error occurred during execution of user defined routine or aggregate 'getsid':

System.IO.FileLoadException: Could not load file or assembly 'System.Messaging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)

System.IO.FileLoadException:

Fix:

You can correct this condition by ALTER ASSEMBLY. For example, if the Messaging DLL is corrupted in the above manner, I would do;

ALTER ASSEMBLY Messaging 
FROM
'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Messaging.dll'
WITH PERMISSION_SET = UNSAFE 
GO

Note, be sure to exit Visual Studio 2012 when you do this. You may get yet another issue which results in "Out of Resource" error.


Other Possible Issues:


  • Exception has been thrown by the target of an invocation when dragging in the LinqDataSource control. -> See This Article



Wednesday, May 16, 2012

SQL Express Connection Times Out Even Though It is Up

Symptom:

I can access the local SQL Express server instance without a problem using the SMSS, but from my application the SQL connection times out almost immediately.

Cause:

In my situation, it was a connection string issue. In production I use a mirrored connection. So just out of a laziness, I just change two of the hosts in the connection string to be the same.

Like this,

Data Source=localhost;Failover Partner=localhost;Initial....

Apparently the driver does not like this type of conneciton string and give you an immediate timeout error.

Fix

Just remove the Failover Partner part and try. It always does the trick to me.


Monday, May 14, 2012

WFC Services Runs OK on Visual Studio Web Server But Not on IIS When Deployed


Symptom:

You have created an WCF "web" service. It debugs and runs fine on the Visual Studio's web server, but when deployed the directory to the IIS 7 (even on the same local machine) you get a script error.

The Root Cause

The WCF is not fully enabled on your IIS 7.

The Fix

The complete fix is from this web site at Microsoft. http://msdn.microsoft.com/en-us/library/ms752252(v=vs.90).aspx 


  • Open the IIS manager and Go to the Default Web Site, Double-click Handler mappings in the Features View.
  • In the list of application mappings, verify that the .svc file for the .NET Framework in use (2 or 4) is mapped to the aspnet_isapi.dll. If the file has not been mapped:
  • Click Add Managed Handler.
  • Type *.svc into the Request path:.
  • Type System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 into the Type textbox.
  • Type svc-Integrated into the Name: textbox.
  • Click OK.
  • Click Add Script Map.
  • Type *.svc into the Request path:.
  • Type %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll into the Executable: text box.
  • Type svc-ISAPI-2.0 into the Name: text box.
  • Under the right "Actions" Panel, select "View Ordered List" then Using the Move Up/Move Down controls, ensure that the managed handler (svc-Integrated) appears before the aspnet_isapi (svc-ISAPI-2.0) handler in the list.
  • Click OK.
  • Give it a shot.


Visual Studio 2010 Reloads Microsoft.VisualStudio.IDE.ToolboxControlsInstaller,ToolboxInstallerPackage'{2C298B35-07DA-45F1-96A3-BE55D91C8D7A} Every Time

Symptom

When opening a forms designer on Visual Studio the following toolbox loads each time and it takes a long time by loading the toolbox with the following information.

Microsoft.VisualStudio.IDE.ToolboxControlsInstaller,ToolboxInstallerPackage'{2C298B35-07DA-45F1-96A3-BE55D91C8D7A}

Root Cause

When you installed a later version of Sliverlight SDK, it has corrupted some data in the older version of the SDK (it is rather complex matter that I fully do not, nor tired to, understand.)

Possible Solution:

There are various options on this, and the best discussion about this is at this URL:  But it appears that this is related to Silverlight SDK corrupting some data in the SDK based on this post.

There are other discussions on this post.

In my specific case, setting

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Packages\{2c298b35-07da-45f1-96a3-be55d91c8d7a}\Toolbox\DefaultItems to 0

made it worse.  I cannot recommend this.

Instead try un-installing and re-installing the Sliverlight SDK in the order of versions to fix the toolbox issue. Namely remove 5.0 SDK and 4.0 SDK then install the 4.0 first then 5.0 if you are still (having to) coding with Sliverlight.

As with anything, approach your fix with a big caution when dealing with config issues like this. Have a good back-out plan like backing up the registry settings etc.

If you don't care so much about Silverlight...

Because of my situation for needing to go beyond Mac and PC audience I have to avoid using Silverlight so I do not need it. If you are on the same camp as I am, just blow away the key altogether.

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Packages\{2c298b35-07da-45f1-96a3-be55d91c8d7a}

For Additional Insights,


You may want to read this article from Infragistics people about How Visual Studio 2010 Toolbox Works.



Thursday, May 10, 2012

ATT Momentum 4G Adaptor Blue Screens Windows 7 X64

Symptom:

When you plug in ATT Momentum 4G (Sierra Wireless Momentum), you get a blue screen (with memory violation from a driver) when the driver in being installed.

Root Cause:

I do not know exactly which driver causes this, but...

It appears that the Sierra driver is not compatible with the USB-3 interface (at least on my ASUS u46s). Try plugging this into a USB-2 interface slot and start the installation over again.

Also, in my situation, I had to call the ATT's automated activation phone line to activate the SIM in it.







Thursday, April 26, 2012

Collecting PDF Form Data with ASP.NET C#

I recently had to investigate the technique to capture the form input data collected on Adobe PDF for radiological procedure report results.

This, though very simple, information was scattered around all over the places so I can provide you the gist of what you need to do by means of a simple demo code.
  • First you will need to use the PDF Form Editor, for example Adobe Acrobat Pro. I am sure there are a lot of different ones.
  • Next you either scan a form or create one which output the usual .doc file.
  • Import the document and edit the form using the PDF form editor, drag and dropping the fields.
  • Finally add a submit button with a submit action of http://localhost/xfdf
  • On Visual Studio, create the xfdf web project and you can add the following code in Page_Load of Default.aspx
public partial class xdf : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var name = "junk.xfdf";
        string filename = Path.Combine(Server.MapPath(""), name);
        using (FileStream fs = new FileStream(filename, FileMode.Create))
        {
            byte[] bytes = new byte[8192];
            int bytesRead;
            while ((bytesRead = Request.InputStream.Read(bytes, 0, bytes.Length)) > 0)
            {
                fs.Write(bytes, 0, bytesRead);
            }
        }
    }
}
  • Compile above code.
  • Submit the PDF form to the URL
Then if you open junk.xfdf on your text editor, you will see something like this. The key part is that you will see the field and value elements in the XML. From this point it is quite easy to parse this stuff using the XDocument class and LINQ.

<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"
><fields
><field name="Heart Rate"
><value
>10</value
></field
><field name="Submit"
/></fields
><ids original="BFF11731D28F744F901901CF60BBED7A" modified="B0328D96D4E3F242A93BC5512C7B97E6"
/></xfdf
>

Monday, April 09, 2012

Getting XTIDE Up on Joyent SmartMachine (Solaris 11)

This is my note on getting the XTide (learn more) up on the Joyent SmartMachine on which I am running various personal web projects. My XTide was previously hosted on a shared Linux machine (i.e., no root access) before but the provider upgraded the Linux and then it broke. Since I now have an Intel Solaris 11 virtual machine of "my own," I have decided to transition to this server (as I find time, of course.) Installing and configuring XTide on a shared machine was a real hassle as they did not have X11 installed and they won't install it for me, but now with the virtual machine in which I have the "root" things are becoming much easier, in addition there are a lot of pre-built installs that's available (still require the root access.) {Why Joyent SmartMachine and Solaris? Don't ask. But I am extremely satisfied with it. }

Perhaps you may have the same problem and here is how I got around the issues.

Note that I am only interested in running this as a command line to compute the tide and graphics in the area I surf using a cron job. So if you have an X-Windows issue, this article won't help much.


Getting It Installed

Getting it installed is fairly simple.
  • The page http://www.flaterco.com/xtide/files.html tells that on Solaris you go to Blastware.COM, but almost all of the mirror sites it points to are broken. Instead, if you go to http://www.opencsw.org/packages/xtide/ it is still avilable. The maintenance of this stopped around 2.10 (in 2008) but for my purposes, it is OK. Someday, when I have more time, I may volunteer to contribute to Opencsw to maintain this. Not now...
  • It comes with required libraries, and also the original harmonics and wvs files it was built with in /opt/csw/share/xtide 
  • If you don't know what I am talking about but you have the root access to the machine, just follow the instructions on the OpenCSW web site, install the pkgutil installer first as a root (if you don't have) and then install the xtide with it. You would be all set in a matter of 5-10 minutes. And if you still don't know what I am talking about, then it is best to ask your IT admin buddy to get that done as it can affect other OpenCSW packages other people may be using on your machine. 
Getting it to Run
  • "Out of the box" by typing in {tide -l "princeton"} it did not run. In fact it threw an exception about saying  the following:

    XTide Fatal Error:  BAD_OR_AMBIGUOUS_COMMAND_LINE

    but do not dismay yet...!
  • Here is what I have done to get it going!
The "tide" command on /opt/csw/bin/tide is a shell script which, in turn, will run tide.bin after "tide" sets various environment variables. There appears to be an issue with the WVS_DIR environment variable and if only have the HFILE_PATH it works (in other words comment out WVS_DIR definition in the tide script), and it will output the tide. The graphics output also worked.

To test if anything works, you can first only EXPORT the HFILE_PATH in your shell then run /opt/csw/bin/tide.bin directly like this.

HFILE_PATH="/opt/csw/share/xtide/harmonics.tcd"
export HFILE_PATH
/opt/csw/bin/tide.bin -l "princeton"

The Harmonics Database Location Names Have Changed

In my old script I had -l "half moon bay." This time it did not work as the program could not find the station name. So be sure that you look at the Location List (http://www.flaterco.com/xtide/locations.html)  that matches your Harmonic file you've downloaded.

Hope this helps in your situation.





Saturday, April 07, 2012

ASP.NET GridView and LinqDataSource Stuff...

The DataGrid is one of the components I use quite a bit in my line of work, and they are convenient.

I have also been using LINQ quite a bit. It is a significant time saver as well as making my code more easier to understand. But until today I never bothered to use LinqDataSource just because I did not spend time to learn a bit about it. Instead I always built the DataSets using the designer. The problem with the Datasets for me is that it does not show me exactly what I am querying easily.

Before I get into that, I have to tell you also that if your requirement is very simple, then you can feed the result of the Linq query directly to the GridView (or other data binding controls.) This might be a great way to bind the pull down menu or a list view with small number of selections.

For example,

var customers = from c in context.customers select c;
gridview1.DataSource = c;

And that really all it takes to feed a GridView. For more information on this, learn from this MSDN page.

But this won't allow you to sort or page the grid. For that purpose you need to attach a LinqDataSource. You can easily do that by:

  • Defining the LinqToSQL object in your project, or pull one in from other assembly
  • Dragging and dropping the LinqDataSource component on to of the GridView. The wizard will show you which of the LinqToSQL database context object to use.

Well that's great, but I really do not want to use the connection string that's built into Web.config. In my case, I pull the connection string common to all my applications from my own company's registry set. But at any rate, you would assign a newly created data context to e.ObjectInstance of the event argument.

So here is another trick.
  • Define an event processing method for ContextCreating event.
  • Re-instantiate the LinqDataContext class object with your connection string. Yes, just the Context is all you need here. The rest will be handled with the LinqDataSource you've created with the designer. (Yes, it is the Data Context object, not the Linq Select result.)

       protected void LinqDataSource1_ContextCreating(object sender,
           LinqDataSourceContextEventArgs e)
        {
            string myConnectionString="your connection string";
            e.ObjectInstance = new MyDataConext(myConnectionString);
        }

Here is another bonus thing you can do. If you do this type of connection string swapping, it is best to create a new context factory class of your own and then call that. This factory class can do the connection string swapping for you. This will centralize the connection string swapping.

In my case, the connection information is stored locally in a registry and many of my own applications pull that information from there at run-time. This way, all I need to do is to set the connection strings once and then all other applications I write will not need separate connection configurations. There are of course many other ways of doing it.


Sunday, March 25, 2012

Mac Lion: ssh hangs

Symptom:

On Mac Lion (10.7.3), when you try 'ssh' it times-out. You know you have the proper login and host parameters because it works from other computers (say Linux or Windows putty, or even running putty on the same Mac!)

Cause:

I do not know, but it appears that the Mac Lion SSH handles UTF-8 character sets in the manner that the remote side do not like.

There is nothing wrong with your network or network provider. Something wrong is introduced in Lion.

Fix:

Essentially finding a line in /etc/ssh_config file that says LANG LC_* should just be commented out. If you do not know exactly what I am talking about the following is the steps to accomplish this.

  1. Open Terminal
  2. sudo vim /etc/ssh_config
  3. Supply your password
  4. Type in below, including the first /
  5. /LANG LC_
  6. This will take you to the line where the problem is
  7. Hit the left arrow key several times,  until you are at the start of the line.
  8. Type i to insert
  9. Type # to comment out the line
  10. Press ESC to exit the insert mode
  11. Type wq (means write quit) to save the file and exit vim
  12. Now close the Terminal, Re-launch it and try ssh again
If you do not want to all of this, simply download other SSH clients and use them.


Saturday, January 21, 2012

Fix! Pythonwin (2.x) Windows 2008 Event Log Text Get Empty String

Symptom:

You used to be able to get the Event Viewer text under Windows 2003 using the following call in Pythonwin. After switching to Windows 2008 or Windows 7 the strings are all empty!

events=win32evtlog.ReadEventLog(hEvent,flags,0)

for ev_obj in events :      
   msg=str(win32evtlogutil.SafeFormatMessage(ev_obj, logType))

Now the majority of "msg" comes out blank. Oddly enough any newer programs the msg come out fine.

Fix:

The string messages logged can also be found as tuples in (using above code example) ev_obj.StringInserts as UNICODE strings.

Therefore, for example, to grab the strings as one msg string, you could write a quick loop like this to get you the full string.

                               msg = ''
             for si in ev_obj.StringInserts :
                   msg = msg + si + ' '                               
             print msg

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.