Roslyn XsltCompile issues

I recently was in the process of upgrading a VS2013 project to VS2015.  I created a new VB Web Application project and it addded the Roslyn compiler components.

In the project were several xsltCompiledTransform calls. There were no compile errors, but during runtime when the xslt.Load method was called, an error was raised:

Exception Details: System.Xml.Xsl.XslLoadException: Type 'Global.System.Web.HttpRequest' is not defined.

It took me a while to figure out that the xslt sheet contained a <msxsl:script language="VB" implements-prefix="VB">  element that was compiled during runtime. I was able to track down the compile files in %user%/AppData/temp.  The compiling was using the Roslyn compilers but for some reason the System.Web assembly was not loaded during the compilation.

So how to fix this error?  I found several ways.
1.  Remove the Roslyn compiler from the web.config.  Comment out the <system.codedom> element and the run time compiler will use the old .Net Framework compiler.
2.  Add  <msxsl:assembly name="System.Web"/> to the msxsl:script element
3. Add "/R System.Web.dll" to the web.config compiler compilerOptions.

Visual Studio Not Stepping Through

I was working on a project and stepping through using the Visual Studio debugger.

When I reached a breakpoint, I wanted to step through to a method in a created class.  But the debugger was not stepping through the code or hitting the breakpoints in the method I wanted to debug.

Turns out that the class I wanted to debug was a partial class.  There was another partial class that was generated with xsd.exe.  One of the attributes of the class was


This causes the debugger to step over the class.  Even other partial classes.

To enable the step through debugging I had to comment out the attribute.

Lost a lot of hair over why it wasn't stepping through

Chrome Trendnet cloud plugin problem

I have a Trendnet cloud IP cam at home.  Ususally I can browse to it through the trendnet proxy.  But today it wouldn't work in Chrome.  Kept prompting me to install the plugin.  I knew Chrome was in the process of not supporting plugins so I figured this was the reason.  So how to enable it?

google "npapi chrome enable"

chrome://flags/#enable-npapi , set to enable

System.Diagnostics.TextWriterTraceListener with ASP.Net 4

I spent hours trying to figure out why my web app wasn't writing to a debug file.

I had this in my web.config

  <trace autoflush="true">
      <add name="textLogListener" type="System.Diagnostics.TextWriterTraceListener"
           initializeData="myapp.log"  />
      <remove name="Default" />

And in my .cs code added
System.Diagnostics.Trace.WriteLine("Hello World");

Worked great in VS2012 but when I published it to a server, no file was created.   

I'm guessing that the ASP.Net compiler wasn't using the trace and debug flags.  The simple fix was adding 

#define TRACE

to the top of the .cs file I was working with.

Simple but not obvious

Get SSH public key fingerprint with powershell

I was working on a project with SSH keys.  I needed to get the key fingerprint but don't have access to ssh-keygen.  So with some poking around I was able to get the MD5 hash of the base64 keyfile.

Here's the code:

$keyFilePath = ""
#Get the key
$rawText = [System.IO.File]::ReadAllText($keyFilePath)
$rawText = $rawText.Replace("`r","")
$rawText = $rawText.Replace("`n","")
$rawText -match "AA.+?=="
$keyText = $Matches[0]

#Compute the hash
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$bd= [System.Convert]::FromBase64String($keyText);
$hash = [System.BitConverter]::ToString($md5.ComputeHash($bd))

Summer Calendar

Here is our summer schedule

Powershell MSMQ

I had to write a function to send MSMQ messages using powershell.  Here is the code that builds on an earlier post sending Unicode text messages with MSMQ

function SendMSMQ

$messageBody = $messageBody.replace("\<\?.+\>\r\n", "").Trim()

if($messageBody.length -gt 0)
 $queue = new-object System.Messaging.MessageQueue($queueName)
 $msg = new-object System.Messaging.Message
 $msg.Label = $messageLabel
 $enc = new-object System.Text.UnicodeEncoding($false, $false)
 $writer = new-object System.IO.StreamWriter($msg.BodyStream, $enc)
 $msg.BodyType = 8
 $queue.Send($msg, [System.Messaging.MessageQueueTransactionType]::Single)
 write-host $messageBody


Win2003 Certs

I was working on installing a ServiceBus 1.1 client app on a Windows 2003 server.  I installed the server certs and crl on the client machine.  However I was still receiving the message:

System.UnauthorizedAccessException: The token provider was unable to provide a security token while accessing 
'https://myserver:9355/ServiceBusDefaultNamespace/$STS/Windows/'. Token provider returned message: 
'The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.'.
 ---> System.IdentityModel.Tokens.SecurityTokenException: The token provider was unable to provide a security 
 token while accessing 'https://myserver:9355/ServiceBusDefaultNamespace/$STS/Windows/'. 
 Token provider returned message: 'The underlying connection was closed: Could not establish trust relationship
 for the SSL/TLS secure channel.'. ---> System.Net.WebException: The underlying connection was closed: Could not
  establish trust relationship for the SSL/TLS secure channel. ---> 
  System.Security.Authentication.AuthenticationException: The remote certificate is
   invalid according to the validation procedure.

When I viewed https://myserver:9355/ServiceBusDefaultNamespace in the browser the cert had an exception of "This certificate has an nonvalid digital signature."
I looked at the cert in certmanager and noticed the signing algorithm was 1.2.840.113549.1.1.11  Apparently the SHA256 algorithm was not installed on the server.  I had to apply a hotfix from

Powershell COM objects

I was trying to create a COM object in powershell like this

$obj= New-Object -ComObject MyProject.MyClass

When I ran it I received this error:
New-Object : Retrieving the COM class factory for component with CLSID {E51BB9FD-F8EF-4636-8DE3-1ADE61B670AD} failed due to the following error: 80040154 Class not registered (Exception 

I just used regsvr32 on the dll so I knew it was registered and I verified it with regedit

Figured out I was running the 64bit version of powershell.  It worked using the 32bit version.

I also noticed that if the COM object is not registered the error is 
New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (Exception 
from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

LocalSTS Web.config

I've been working on some Windows Identity Framework project and have been using the cool localSTS tool for claims authentication.  The one thing I did notice is that the web.config for the project is overridden when the localSTS is configured.  After my project was running correctly, I went in and added some claims to the existing configuration. When I started the project again the Windows Cardspace app popped up and there was a message

"Incoming policy failed validation."

Took me forever to figure out that the localSTS config replaced the existing issuermetadata element with

              <issuerMetadata address="https://localhost/adfs/services/trust/mex" />

The address should be something like https://localsts:port/wsTrustSTS/mex

How to get Service Bus for Windows client config

I installed the Service Bus for Windows Server application but did not save the client connection string.  I found out later how to do it so here it is.

1.  Open the Service Bus Powershell link under the Service Bus group (or add the ServiceBus PowerShell ps1 file)
2.  Execute the Get-SBClientConfiguration command.  

SAML2 FederationMetadata validation

I was working on a project using a SAML2 FederationMetadata document.  The Xml signature of the document had to be verified.  I had some issues out of the box so I thought I'd document them

"SignatureDescription could not be created for the signature algorithm supplied."

First issue was with the signature using the "" encryption.  For some reason it's not included in System.Security.Cryptography.Xml.SignedXml so the following class has to be added

    public class RSAPKCS1SHA256SignatureDescription : SignatureDescription
        public RSAPKCS1SHA256SignatureDescription()
            base.KeyAlgorithm = "System.Security.Cryptography.RSACryptoServiceProvider";
            base.DigestAlgorithm = "System.Security.Cryptography.SHA256Managed";
            base.FormatterAlgorithm = "System.Security.Cryptography.RSAPKCS1SignatureFormatter";
            base.DeformatterAlgorithm = "System.Security.Cryptography.RSAPKCS1SignatureDeformatter";

        public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key)
            AsymmetricSignatureDeformatter asymmetricSignatureDeformatter = (AsymmetricSignatureDeformatter)
            return asymmetricSignatureDeformatter;

Before you create the SignedXml object the Encrytion algorithm has to added to the config
            CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), "");

            SignedXml signedXml = new SignedXml(metadataXmlDocument);

Net issue I had was the signedXml.CheckSignature(certificate, false) returning false for valid signed files.  The issue was that the certificate was not in the trusted root certificate store.  Why that matters I'm not sure but the issue went away after I added it.

VB multiline string as XML Literals

Probably known by most programmers, but I want to document it so I can find it myself later.

An easy way to create a multiline VB string is to create a xml literal and use the value

Dim myTest = <string>Here is a multi
line string that I want to use in
some other code.  It
helps the readability and
cut and paste functionality.
Even if this is a poor example

Dim strInside as string = myTest.value

SearchServer2008Express Search Webservice

I was working on calling the Search Server 2008 Express search webservice from Powershell.  I kept getting

 <ResponsePacket xmlns="urn:Microsoft.Search.Response"><Response domain=""><Status>ERROR_NO_RESPONSE</Status><DebugErrorMessage>The search request was unable to connect to the Search Service.</DebugErrorMessage></Response></ResponsePacket>

I checked the user authorization, the webservice search status, even the WSDL.  

Turns out the URL for the SearchServer2008 search webservice was incorrect.  I was calling 
$URI= "http://ss2008/_vti_bin/spsearch.asmx?WSDL"
and it should have been
$URI= "http://ss2008/_vti_bin/search.asmx?WSDL"

Here is my sample powershell script:
# WSS Documentation


#Bad SearchServer2008Express Search URL 
$URI= "http://ss2008/_vti_bin/spsearch.asmx?WSDL"
#Good SearchServer2008Express Search URL 
$URI= "http://ss2008/_vti_bin/search.asmx?WSDL"

$search = New-WebServiceProxy -uri $URI -namespace WSS -class Search -UseDefaultCredential 

$queryXml = "<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'>
  <Query >
      <Format revision='1'>urn:Microsoft.Search.Response.Document.Document</Format>
      <QueryText language='en-US' type='MSSQLFT'>SELECT Title, Path, Description, Write, Rank, Size FROM Scope() WHERE CONTAINS('Microsoft')</QueryText>
      <!--<QueryText language='en-US' type='TEXT'>Microsoft</QueryText> -->
$statusResponse = $search.Status()
write-host '$statusResponse:'  $statusResponse
$GetPortalSearchInfo = $search.GetPortalSearchInfo()
write-host '$GetPortalSearchInfo:'  $GetPortalSearchInfo
$queryResult = $search.Query($queryXml)
write-host '$queryResult:'  $queryResult

Runnin Framework 4.0 with Powershell

I had problems running scripts with Framework 4.0 assemblies I created.  The error I was getting was 
Add-Type : Could not load file or assembly 'file:///C:\myDLL.dll' or one of its depend
encies. This assembly is built by a runtime newer than the currently loaded run
time and cannot be loaded.
I had to add the supported framework to the powershell.exe.config file.
<supportedRuntime version="v4.0.30319"/>

I still had a problem running the assembly so I had to recompile and set "Generate serialization Assembly" to off.

set jqueryUI ThemeRoller cookie

Seems to me that all users prefer a different color scheme for the web apps they work on.  With jQueryUI, the themes are available and can be chosen with the themeswitcher gadget.  Howerver, out of the box the chosen them only lasts as long as the session.  I wanted to change it to last longer.  There are some examples on the web of modifying the jqueryUI code, but I found a simpler fix. Change the jqueryUI cookie expire date

    onSelect: function(){
     $.cookie('jquery-ui-theme',$.cookie('jquery-ui-theme'),{ expires: 7 });
    alert("Current Theme:" + $.cookie('jquery-ui-theme'));

jqGrid inline afterSave event

A quick note on the inline afterSave event in jqgrid 4.3.1

I was trying to refresh the grid after adding a row using the inlineNav add row button.  I couldn't fire the afterSave method to refresh the grid.  Turns out that onSuccess has to be true before afterSave is fired.

{ name:

'EditOptions', index: 'EditOptions', hidden: false, width: 80

,formatoptions: { keys:

false, editbutton: true, delbutton: true, onSuccess: true,afterSave:function(rowid){alert('afterSave'); subgrid.trigger("reloadGrid"); } }

, formatter:

'actions', search: false},

Good Luck

Powershell Emailing Strings as attachments

I was working on a project to send a html attachment in a powershell script.  I have the HTML string so all I want to do is create an attachment from the string.  Here's the code:


$SMTPserver = ""
$from = ""
$to = ""
$subject = "Test PS Attachment"
$emailbody = "test"
$attText = "The text of the attachment"
$attName = "Test.txt"

$mailer = new-object Net.Mail.SMTPclient($SMTPserver)
$msg = new-object Net.Mail.MailMessage($from, $to, $subject, $emailbody)
$att = [System.Net.Mail.Attachment]::CreateAttachmentFromString($attText,$attName)

$msg.IsBodyHTML = $false

That should get you started.

BizTalk 2010 SMTP mailer

I checked the SMTP headers on an email sent from the Biztalk 2010 SMTP send port.

X-Mailer: Microsoft CDO for Windows 2000

Really?  CDO Really?

IIS 7 URL Rewriting

I was working on a MVC3 project using jQuery to populate a text input in an iframe element from the parent.

The catch is that the iframe source is on a different domain.

When I first tried to do it, the javascript gave me the Permission Denied error for trying to access the iframe document in a different domain.

If the domain of the parent and iframe child are the same this Permission Denied error will not be encountered.  To get the iframe domain the same as the parent I needed to use a proxy to fetch the page from the remote site, change the domain and display it in the iframe.  Also the interactions in the iframe need to go back to the remote site.

To get this to work I downloaded the IIS URL Rewrite Module

I had to create some rewriting rules to do the proxy.  This blog post
has a good description of how to create the rules.

jqGrid Row Edit Buttons

I've been working with the jqgrid and have been really impressed with the ease of use.  One issue I was having was with the action buttons on the row.  If a new row is selected, the action buttons wouldn't toggle back.  I had to toggle them myself in the onSelectRow function.

Here is a sample jqgrid based on the jqgrid samples


<html xmlns="">
        <link href="/Content/Site.css" rel="stylesheet" type="text/css" />
        <link href="/Content/jquery-ui-1.8.7.css" rel="stylesheet" type="text/css" />
    <link href="/Content/ui.jqgrid.css" rel="stylesheet" type="text/css" />
    <link href="/Content/ui.multiselect.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.6.1.min.js" type="text/javascript"></script>
    <script src="/Scripts/modernizr-1.7.min.js" type="text/javascript"></script>

    <script src="/Scripts/grid.locale-en.js" type="text/javascript"></script>
<script src="/Scripts/jquery.jqGrid.min.js" type="text/javascript"></script>

<script type="text/javascript">
    jQuery(document).ready(function () {

var lastsel2
 datatype: "local",
 height: 250,
    colNames:['ID Number','Name', 'Stock', 'Ship via','Notes','Edit'],
     {name:'id',index:'id', width:90, sorttype:"int", editable: true},
     {name:'name',index:'name', width:150,editable: true,editoptions:{size:"20",maxlength:"30"}},
     {name:'stock',index:'stock', width:60, editable: true,edittype:"checkbox",editoptions: {value:"Yes:No"}},
     {name:'ship',index:'ship', width:90, editable: true,edittype:"select",editoptions:{value:"FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX"}},
     { name: 'note', index: 'note', width: 200, sortable: false, editable: true, edittype: "textarea", editoptions: { rows: "2", cols: "10"} },
       { name: '', index: '', width: 80, formatoptions: { keys: false, editbutton: true, delbutton: true }, formatter: 'actions' } 
 onSelectRow: function(id){
  if(id && id!==lastsel2){
      jQuery('#rowed5').jqGrid('restoreRow', lastsel2);

      $("tr#" + lastsel2 + " div.ui-inline-edit, " + "tr#" + lastsel2 + " div.ui-inline-del", "#rowed5").show();
      $("tr#" + lastsel2 + " div.ui-inline-save, " + "tr#" + lastsel2 + " div.ui-inline-cancel", "#rowed5").hide();
  // Let the action buttons set the edit row
  // jQuery('#rowed5').jqGrid('editRow',id,true);
 editurl: "server.php",
 caption: "Input Types"

var mydata2 = [
  {id:"12345",name:"Desktop Computer",note:"note",stock:"Yes",ship:"FedEx"},
  {id:"23456",name:"Laptop",note:"Long text ",stock:"Yes",ship:"InTime"},
  {id:"34567",name:"LCD Monitor",note:"note3",stock:"Yes",ship:"TNT"},
  {id:"56789",name:"Laser Printer",note:"note2",stock:"Yes",ship:"FedEx"},
  {id:"67890",name:"Play Station",note:"note3",stock:"No", ship:"FedEx"},
  {id:"76543",name:"Mobile Telephone",note:"note",stock:"Yes",ship:"ARAMEX"},
  {id:"98765",name:"Matrix Printer",note:"note3",stock:"No", ship:"FedEx"}
for(var i=0;i < mydata2.length;i++)

 <table id="rowed5"></table>



I was working on a MVC3 project with jqGrid using JSON.  The data was created using EF4 Code First.  Took me a while to hook up the grid and actually having it post back to the server to retrieve the JSON.  I was having issues with my int ID column not formatting to JSON. 

LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.

StackOverflow had some responses to use


Then I received a different error

The specified method 'System.String StringConvert(System.Nullable`1[System.Double])' on the type 'System.Data.Objects.SqlClient.SqlFunctions' cannot be translated into a LINQ to Entities store expression.

What I ended up doing is creating a list of the products and then looping through them

var products = from product in db.Products
               select product;
var prodList = products.ToList();



Google Toolbar 7 Buttons

My computer installed the latest google toolbar and everything was screwed up.  Fonts and colors for searching?? Missing toolbar buttons??  I guess I should work at google where getting nothing done is working.

Anyway I found a cryptic blog post about the "missing buttons" (  Apparently they did it for my own good and to clean up the toolbar.  Under "More >>" the buttons are there.  Click on them and they return to the toolbar.

Thanks for letting us know about the changes Google.

Powershell FTP

I've been looking for a replacement for my powershell script used to ftp files.  It currently uses the Windows ftp.exe application with a command file.  Well the script has been causing problems and files have been truncated or lost.  I decided to look into a replacement.

I tried ftpwebrequest but when moving multiple files the login happens over and over.

I found Alex FTPS Client on codeplex at  Seems to do what I needed. 

Here is a Powershell script to use it to connect, list contents, get the files and put the files

add-type -path "C:\AlexPilotti.FTPS.Client.dll"

$ftpServer = ""
$username ="validUser"
$password ="myPassword"
$localToFTPPath = "C:\ToFTP"
$localFromFTPPath = "C:\FromFTP"
$remotePickupDir = "/Inbox"
$remoteDropDir = "/Outbox"
$SSLMode = [AlexPilotti.FTPS.Client.ESSLSupportMode]::ClearText

$ftp = new-object "AlexPilotti.FTPS.Client.FTPSClient"
$cred = New-Object System.Net.NetworkCredential($username,$password)

"Get DirectoryList"

"Get Files"
$ftp.GetFiles($localFromFTPPath, $false)

"Put Files"
$ftp.PutFiles($localToFTPPath, $remoteDropDir, "*.edi", [AlexPilotti.FTPS.Client.EPatternStyle]::Wildcard, $false, $Null)


W006.15 isp or T-mobile Network Error.

I just bought a new T-Mobile G2.  I wanted to turn on Wifi calling but kept receiving "W006.15 isp or T-mobile Network Error" and asking me to register. 

After doing some research I looked at my cable modem/router logs and config.  There were fragmented packets originating from the phone and the incoming fragmented packets were blocked.  I disabled the "Block fragmented packets" setting and the phone was able to connect for Wifi calling