My Software Notes

Useful things I discover

“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

Windows 8 So Far

leave a comment »

I haven’t had a chance to use the new touch features of Windows 8, but even so I like it so far.

My main “likes” are the speed improvements.  It boots up way faster, it seems to run every app I use faster and IE10 is way faster.

So, I’m happy with it.

I’ve gotten used to the Start Screen rather than the Start Menu, although I would like to be able to use the old Start Menu from the Desktop.  When I eventually get a touch screen I’ll probably stop complaining about that.

Another sign that Win 8 will succeed is that a co-worker of mine bought an All-In-One Win 8 computer with touch for his computer-illiterate father and his dad immediately started using it and figured it all out with almost no help.

So for us .NET, MS development types, this all bodes well.

Written by gsdwriter

December 4, 2012 at 11:34 am

Posted in Musings, Windows 8

Why Windows 8 will be a huge success

with one comment

I really like Windows 8.  But I’m just a lowly developer who uses a computer all day long so I’m not an average user and my opinion on the success or failure potential for Windows 8 doesn’t really count for much.

But this morning I had confirmation from an unbiased source that Windows 8 will be an enormous success.

This morning, my wife, who has NEVER EVER praised a piece of software, never mind an operating system, said, “I love Windows 8.”

I almost choked on my mouthful of breakfast and it took me several minutes to recover from the shock.  All I ever got from her before this were complaints that “Yahoo mail is slow” or “Facebook is slow” or “I can’t find my file in Microsoft.”  But this morning she told me, “I love Windows 8.  It’s so fast.”

And that’s also the main reason I like it – IT’S SO FAST.  The Windows 8 machine my wife has been using is a machine that previously ran Windows 7, so it’s not new hardware that’s causing the improvement.  I also installed it on a machine at work where I upgraded rather than running a fresh install and IT’S SO FAST on that machine too.  So the speed improvement is not due to hardware or cleaning out the Registry.

So if my computer semi-literate wife “loves Windows 8″ then there is no question it’s going to be a success.

What’s even more amazing is that because she actually likes the Windows 8 user experience, she is finally willing to have me show her how to do other things on the computer.  So this weekend I showed her how to use OneNote and she started using it.  Then she wanted me to show her how to customize the lock screen and she wanted a desktop theme installed.  She NEVER EVER asked me for any of that before.  In the past she used it for her email and Facebook and Netflix and that was it.  Now she’s actually interested in learning more and using more.  That is a feat I haven’t been able to achieve after years of trying and now, after only three weeks, Windows 8 has somehow gotten her interested in learning more about all aspects of the computer.

So, there you are.  That is why Windows 8 will be a huge success.

Written by gsdwriter

October 22, 2012 at 11:08 am

Posted in Musings, Windows 8

Adding PowerShell Automation to a .NET Application

leave a comment »

So I want to add PowerShell automation to my .NET app and according to MSDN (How to Write a Simple Host Application) I have to use the “Browse” feature of the “Add Reference” dialog in Visual Studio.  The location for the System.Management.Automation.dll is given as “Windows\assembly\GAC_MSIL\System.Management.Automation”.  But that may not always be correct.  See my note at the end.

Another, and I think better, way to do it is to open your project file and in the first “<ItemGroup>” section, add:

    <Reference Include="System.Management.Automation" />

This worked great for me.

Something to watch out for if you use the “Browse” method and you are using the Powershell 3 CTP: The dll is in a different location:

C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35

When I used the “Reference” method, Visual Studio referenced it without me having to do anything more.  Now that’s what I call service.

Written by gsdwriter

August 28, 2012 at 3:46 pm

Posted in .NET, Powershell, Visual Studio

Tagged with ,

Follow

Get every new post delivered to your Inbox.