Monday, July 28, 2014

How to Add a Folder to a Homescreen on the Google Experience Launcher

I just installed the Google Experience Launcher on my Galaxy Note 3.  I could figure everything out like how to add new pages (by dragging an existing icon to the right), but couldn't figure out how to add a new folder.  I tried looking in settings, blah blah.. but didn't find any help or online either.  So I tried a couple of things, and finally it came to me to try just dropping one icon on top of another icon.  Boom!  It made a folder.  In fact it made a folder called "Unnamed Folder"  so if you tap on that "unnamed folder" text, it allows you to edit it. 

Sunday, November 17, 2013

.NET Framework 4.0 and the Dreaded CS0246: The type or namespace name 'XXXX' could not be found

I don't think of myself as a beginner or some kind of noob.  I've got 19 years in this business for goodness sake, but when trying to post a simple .NET Framework 4.0 web site to a Windows 7 box for testing, I feel like I got my behind whipped!  

To help others from having to go through this, I wanted to post some help to my future self and anyone else struggling with this.

My development box is a Windows 8.1 box running Visual Studio 2012.  For the sake of making this short and sweet, I have a solution with a web site project and a C# class project.  In the web site I have a single page: default.aspx , which calls the .dll for some quick results on the page.

Everything was absolutely fine when I compiled and ran the project.  It worked as expected, so I wanted to post the .dll to my test server so a friend could try it out from his phone.  I spent hours trying to get it to work and kept getting the dreaded "The type or namespace name" error when I would try to run the page from that test box.

Instead of going through all of the bloody details, let me simplify this by just stating how I was able to finally make it work.

First on my Windows 7 (x86) test box, I have turned on IIS, installed the .NET Framework 4.5, etc.. all the standard stuff.  Next the following steps also had to be done:

1. I discovered that in order to be able to post this C# class .dll into the GAC on that Windows 7 box, I had to enable a strong name.  To do this, I opened the property pages of the class in Visual Studio, then went to the "Signing" tab and clicked the "Sign the assembly" checkbox.  It asked me for a strong name key file, so I just named it the same name as the .dll.  It also asks for a password when you create the strong name key file, but I elected not to for this prototype.

2.  I created a new virtual web site on the Windows 7 test box and made sure to pick an application pool which uses the .NET Framework 4.0.

3.  On my test box, I copied the files into the root folder of the virtual web site, and the .dll file into the \bin subfolder. I discovered that if you don't use an IIS web site when you create these kinds of projects, it uses "IIS Express" when running and debugging the project in Visual Studio, and it won't need to put the C# class in the GAC on your local machine.  But when you post it to the test box, you have to either create an installer which does all this for you, or you have to take a manual step to install the .dll on the Windows 7 box (and I think Server versions as well, I haven't tested this theory).  So on the Windows 7 box, I installed the Windows 7 SDK with Framework 4.0.

4.  I found out that you have to add the .dll to the GAC on the text box by running this from the command prompt:

gacutil /i [name of your .dll]

However, I had a heck of a time figuring out that there are a couple versions of gacutil.exe installed.  The one I had to use was for .NET framework 4.0 and it was found in the following folder:

C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\gacutil.exe

After running the gacutil.exe utility to add the assembly to the cache, I ran this command line to find out what the PublicKeyToken was:

gacutil /l [name of your .dll]

It nicely reports that the new assembly is in the cache.

Notice that it also reports the PublicKeyToken attribute which you need for the next step.

5.  Now I had to edit the web.config file on the test box (and for good measure on the local development box) to add this assembly reference.  It blew me away that I had to add this in the web.config file even though it was working perfectly fine in development mode by adding the class reference to the web site and by adding the "using [your class namespace name];" in the code.  The reference looks like this:


After I did all of these steps, I finally got the page to work on the test box.  It might have just been quicker for me to create an installer, or maybe use the publish option, but now that I know what to do for this kind of quick test, I think it is faster to just do these manual deployment steps.

If this helps just one person save some frustrating hours, it was worth the time it took to type this up.