Copy to local drive before running installations

I’ve downloaded Windows Identity Foundation from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17331,
but when I  was trying to install, it returned
—————————
Windows Update Standalone Installer
—————————
Installer encountered an error: 0x80070003
The system cannot find the path specified.

—————————
I’ve tried a few other similar downloads, and all had the same error,
Finally I’ve realized, that they don’t want to run from shared drive.
After I’ve copied to local drive  Windows6.1-KB974405-x64.msu, I was able to install it.

Extract substrings starting with known text from long lines

I’ve received a .csv report from TripWire logs, where each entry is a long text strings.
I needed to extract some substring from each row, e.g “ErrorCode: ABC1234” where preceding text is constant, but actual error code could be different.
In TSQL I can do someting similar using patIndex and substring, e.g.
select text,substring(TEXT,PATINDEX (‘%ErrorCode:%’,TEXT),10)

In C# I can do it using RightAfter and TrimLength from My StringHelper
RightAfter(Text,”ErrorCode:”).TrimLength(10)  

But I was able to do it In Visual Studio Editor using replace and tick ‘Use regular expressions”

Find what
^.*ErrorCode:
replace with
ErrorCode:

I would appreciate suggestions to do similar extracts using other tools.

Related post

Remove empty lines in text using Visual Studio.

CodePlex downloads without strong name for an assembly

I wanted to use http://cache.codeplex.com/ in my solution, but it caused compile error
Assembly generation failed — Referenced assembly does not have a strong name

REASON: When you compile an assembly with a strong name, any referenced assemblies must also have strong name.

I could sign Cache project using Visual Studio or using commands as described in “Tip related to strong name”. But It also required to sign referenced DLLs, like BplusTree from http://bplusdotnet.sourceforge.net/

Fortunately I’ve found the discussion The assembly strong naming conundrum where most of the people agreed that

if nothing was strong named (outside of framework assemblies), we would be better off. As long as you don’t attempt to use the GAC (which has many issues), then strong naming just doesn’t seem to give much tangible benefit. And it certainly does cause pain, because you start needing to add binding redirects left and right when you update some components.

If you’re building “just” websites maybe you don’t need strong naming at all.

It sounds reasonable and we decided to get rid of assembly signing. It takes some time to remove Sign, if you have more than 50 projects in the solutions. Also for InternalsVisibleTo Attribute it’s required to remove public key, because DLLs are not strongly named anymore.


However in codeplex projects it would be a good idea to provide signed DLLs in release download.

Custom HTTP response header to identify server in a farm.

We wanted to follow recommendation from http://omaralzabir.com/best_practices_for_creating_websites_in_iis_6_0/ to

“add “From” header and set the server name. I do this on each webserver and specify different names on each box. It’s handy to see from which servers requests are being served. When you are trying to troubleshoot load balancing issues, it comes handy to see if a particular server is sending requests”

 

However one of the client of our rest service reported that From value in the response header is not valid and causing the .net HttpClient to throw an exception.

Innermost Message: The header cannot be added. Make sure to add request headers to HttpRequestMessage, response headers to HttpResponseMessage, and content headers to HttpContent objects.

Innermost Source: Microsoft.Net.Http

Innermost StackTrace: at System.Net.Http.Headers.HttpHeaders.CheckHeaderName(String name)

  at System.Net.Http.Headers.HttpHeaders.AddWithoutValidation(String name, String value)

  at System.Net.Http.HttpClientChannel.AddHeaderValues(WebHeaderCollection source, Int32 index, String header, HttpHeaders destination)

  at System.Net.Http.HttpClientChannel.CreateResponseMessage(HttpWebResponse webResponse, HttpRequestMessage request)

  at System.Net.Http.HttpClientChannel.GetResponseCallback(IAsyncResult ar)

HTTP/1.1 200 OK

Date: Fri, 09 Mar 2012 07:29:25 GMT

Server: Microsoft-IIS/6.0

From: FARMSRV04


According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

The From request-header field, if given, SHOULD contain an Internet e-mail address for the human user who controls the requesting user agent. The address SHOULD be machine-usable, as defined by “mailbox” in RFC 822 [9] as updated by RFC 1123 [8]:


 

      From   = “From” “:” mailbox

An example is:       From: webmaster@w3.org

This header field MAY be used for logging purposes and as a means for identifying the source of invalid or unwanted requests. It SHOULD NOT be used as an insecure form of access protection. The interpretation of this field is that the request is being performed on behalf of the person given, who accepts responsibility for the method performed. In particular, robot agents SHOULD include this header so that the person responsible for running the robot can be contacted if problems occur on the receiving end.

Actually standard doesn’t specify From as expected RESPONSE header(only as request).
however we should rename the custom header to something else to avoid conflicts, e.g.


FromServer: FARMSRV04