My Software Notes

Useful things I discover

Environmental Variables Disappearing In Windows

leave a comment »

I started noticing it a couple of days ago: icons on my task bar, such as the File Explorer, stopped working and gave me that annoying “application cannot be found” message. Other programs just stopped working.

I hunted around and found that my PATH variable in a console window was only listing the additional path items from the “User” environment. The “System” (aka “Machine”) PATH environmental variable was not being appended to the front of the “User” PATH.

I tried to open “Computer > Properties > Advanced Properties” and it said it couldn’t find the Advanced Properties dialog and it gave the path to the app using “%windir%”.  So I opened up a console and typed “SET” and the majority of the System environmental variables were missing.

What was going on?

I hunted and hunted and finally found this: Windows 7′s PATH and environment variables are corrupted.

Can you believe that? When your path goes over 2048 characters long the entire environmental variables handling in Windows goes haywire.

I edited my PATH and took out a bunch of duplicate entries (what added those?), got it down to a much smaller size and suddenly my Win7 machine was working perfectly again.

It seems like a serious omission that Windows gives no warning at all that there is a problem and we poor buggers have to figure out what to do.

I hope this post helps someone out there with the same headache.

Written by gsdwriter

October 31, 2013 at 12:05 pm

ISO Mounting Software

leave a comment »

If you are running Windows 8 then mounting ISO images is built in.

If you are running an earlier Windows version then you need software.  The simplest I’ve found is Virtual CloneDrive.  There are others that people seem to like, such as MagicISO and DaemonTools, but you aren’t supposed to install their free versions for commercial use, but Virtual CloneDrive is completely free and works great.

BTW: Don’t even think of using Microsoft’s Virtual CDRom Control Panel – it works on XP, but not on anything later without jumping through so many hoops that your legs will give way.

Written by gsdwriter

July 1, 2013 at 2:22 pm

Posted in Tools

Dev Humor: Apple’s next connector?

leave a comment »

Martin Fowler is a cool guy and I love his sense of humor:  Apple’s next connector?

If you don’t get which song the “next connector” name is coming from, then watch the video below:

Written by gsdwriter

May 30, 2013 at 9:45 am

Posted in Humor

“Unable to attach to process. A debugger is already attached.” (VS 2010, Classic ASP)

with 2 comments

Situation:

A fellow developer was using Visual Studio 2010 SP1 to debug a classic ASP application.  He attempted to attach to the IIS process, w3wp.exe and received the error message: “Unable to attach to process. A debugger is already attached.”

Data:

He is running Windows 7, 32 bit. (But I reproduced the error on Win7 64 bit.)

He is using IIS 7.5.

Yesterday he installed IE 10 32 bit. (Yesterday I installed IE 10 64 bit.)

We looked in Process Explorer but no debugger was running that we could see.

We tried changing the “Attach to” type in the “Attach to Process” dialog, but it had no effect.

We tried all sorts of things but nothing made any difference.

I found this forum article:  Visual Studio 2010 debugger already attached classic ASP

I tried debugging the same ASP site by attaching to the IIS process, using VS 2012 and it worked perfectly.

Solution:

Use VS 2012 or revert from IE 10 for Win7 to IE 9.

 

My fellow developer is installing VS 2012. (I don’t know why he didn’t do it already – heck, it’s worth it just for that cool Dark Theme.)

I hope that helps anyone hitting this issue.

Written by gsdwriter

March 1, 2013 at 1:36 pm

log4net – Quick and Dirty set up

leave a comment »

I do this infrequently enought that I have to keep going back to old projects to see the steps.  So, I’m putting them here to save me the hunting.

  1. Use NuGet to pull in the Log4Net binaries, etc. to your project.
  2. Add to your web.config <configSections> element:
    <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
  3. Add to your web.config under the root <configuration> element (modify the appender as you wish):
      <log4net threshold="All">
        <appender name="LogFile" type="log4net.Appender.FileAppender" >
          <file value="c:\logs\MyLog.log" />
          <appendToFile value="true" />
          <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date %-5level %-40logger{2} - %message%newline" />
          </layout>
        </appender>
    
        <root>
          <level value="All" />
          <appender-ref ref="LogFile" />
        </root>
      </log4net>
  4. Add to your AssemblyInfo.cs file:
    [assembly: log4net.Config.XmlConfigurator(Watch = true)]
  5. In the file where you want to use it:
    using log4net;
  6. Example of use:
    var log = LogManager.GetLogger(System.Reflection.MethodBase
        .GetCurrentMethod().DeclaringType);
    log.Error("This is a test log message with an exception", 
        new Exception("Test Exception"));

That should do it.

Examples of config: log4net Config Examples

Written by gsdwriter

January 31, 2013 at 1:07 pm

Posted in .NET, Logging, Tools

Windows 8 in 4 or 24 minutes

leave a comment »

Two videos by Scott Hanselman to get someone up and running on Windows 8.  The first video takes 4 minutes and if you blink you’ll miss something important.  I rate it “R” for “Really Geeky”.  The second video takes 24 minutes and I rate it “PG” for “Parents and Grandparents”, because they’ll be able to follow it.

Video 1: Learn Windows 8 in 3 Minutes (Ok it’s really 4)

.

Video 2: The Missing Windows 8 Instructional Video – Who moved my Windows 8 Cheese?

Hope they help.

Written by gsdwriter

January 14, 2013 at 12:31 pm

Posted in Windows 8

CRM 2011 – Ajax call using jQuery returns “No Transport” error

with 2 comments

I was trying to call the OData service in CRM.  I was using the good old jQuery $.getJSON function.  It was failing with the “errorThrown”  parameter telling me “No Transport”.

I had a vague recollection of hitting this error in a different context last year, so I looked it up and found that the error can be caused by a cross-domain Ajax request.

For Example:

Your browser url is “http://crm/MyCorp” and your Ajax call uses http://server03/.

Gotcha

On the surface, this didn’t really explain my problem.  My browser was pointing at my CRM installation and I was making a call to the OData service on the same installation.  So why the cross domain issue?

Then it hit me.  There were two ways to get to the CRM installation.  There was a DNS entry for “crm” and there was one for the server itself called “crmserver03″.  I checked what url was being used by running the JavaScript debugger (good old F12) and there was the answer:  My browser was pointing at http://crm/MyCorp and the Ajax call was going to http://crmserver03/MyCorp.  Huh?

I hunted a bit more and here is what I found:  I was using the Xrm.Page.context.getServerUrl function to make sure I had the right server url BUT this function does not return the domain the browser is using.  Instead it returns the domain that was set in the config of the CRM installation.

See:  How does “Xrm.Page.context.getServerUrl” work?

So if you navigated to the CRM installation using the domain name “crm” and the config says “crmserver03″, then calling getServerUrl will return a different domain to the one your browser is using.  In this case, if you use getServerUrl to build the URL for an Ajax call then you will be using a different domain name and will get the “No Transport” error (unless you’ve done this: How to make a cross-domain Ajax call in jQuery).

I think that’s a bug in gerServerUrl.

Anyway.  Here is my fix:

var url = window.location.protocol +  "//" +  
    window.location.host + "/" + 
    Xrm.Page.context.getOrgUniqueName();

Or, for a relative url, you can use:

var url = "/" + Xrm.Page.context.getOrgUniqueName();

Whichever suits your needs.

Update: See comment below from Carsten Groth and my reply for a new Xrm function that returns the correct url.

Written by gsdwriter

January 7, 2013 at 1:48 pm

Follow

Get every new post delivered to your Inbox.