Archive

Archive for the ‘Uncategorized’ Category

VSTS package management with teamcity nuget authentication issue

October 6th, 2017 No comments

The problem

You have your nuGet packages being hosted on VSTS, and published a feed via package managment.

Using teamcity to setup a build where the visual studio solution needs to reference your custom nuGet packages from VSTS .

You setup the first build step as “Nuget Installer” and configure it to restore your packages from the .sln file.

When you run the build it will fail with authentication issues connecting to the VSTS Nuget feed, with a 401 Unauthorized.

The solution

In your build configuration:

  1. click “Build Features”.
  2. Choose “Add Build Feature
  3. In the drop down choose “nuGet Feed Credentials”
  4. Enter the path to your VSTS nuget package
  5. Enter your credentials
  6. Save it

Now run your build and it will successfully authenticate you against VSTS and download your packages.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: Uncategorized Tags:

Grant Connect SQL Server – TSQL

July 27th, 2017 No comments

The issue

You are having connection problems to the database and all the permissions look correct but you cannot login.
Fire up the SSMS and expand the Security tree at the individual database and you notice that your login is there but with a little red down arrow.

The Fix

You need to grant “Connect” to your user.

Assume your user is a domain account DOMAIN\username

use MyDatabase 
GO

Grant Connect to [DOMAIN\username];
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: SQL Server, T-SQL, Uncategorized Tags:

Windows 10 – KB3147458 – Windows update failure – 0x80070003 – ERROR_PATH_NOT_FOUND – FIXED!!

April 26th, 2016 2 comments

The Problem

I have numerous windows 10 machines and my desktop PC has started failing to apply the windows updates.

These two windows updates failed to install

  • Cumulative Update for Windows 10 Version 1511 for x64-based Systems (KB3140743)
  • Cumulative Update for Windows 10 Version 1511 for x64-based Systems (KB3147458)

Note: because of these issues I have set my windows update to notify and let me choose when to download and install

Setup Windows Update via Group Policy

The Symptoms

  • You are told there is a new update and you let it download and install.
  • Once completed you are asked if you wish to restart, so click restart
  • You are told that it is getting ready to install updates
  • In my case it gets to 3% and then reboots
  • Next it gives a message, “Cannot complete install. Undoing changes”
  • The computer reboots again
  • On login, you are told some udpates were unsuccessful

The Issue

In my particular instance this fixed the issue.

I first went and viewed the log file: C:\Windows\Logs\CBS\CBS.log
Depending on how long it has been since the error occured you may need to look for a file called “CbsPersist_20160425131704.log” where the number is the date/time of when the log file was created.

Open the file and search for “0x80070003 – ERROR_PATH_NOT_FOUND”

I found mine is a section as follows:

The issue is that one or more of the 16 drivers it is attempting to update has failed to be installed with a Path Not found error, but which one/s?

To find the details of the erroring driver update go to this file: c:\windows\Inf\setupapi.dev.log

Open this file and search for “Exit status: FAILURE”

I found the following, item of interest:

As you can see it is saying path not found in the FileRepository folder.
So I went looking and its right, I had no “capimg.inf_amd64_5a4379f63bea786c” folder!

The fix

In my case I have many other healthy windows 10 machines so I went and looked and sure enough they had the missing folder.

So I firstly copied the folder onto a usb key from the healthy machine.

There is a security issue with the FileRepository folder in that you will have no permissions on this folder.
To copy the “capimg.inf_amd64_5a4379f63bea786c” folder into the FileRepository directory you will need to go into the Advanced security and take ownership first. I am an admin on my PC, so I changed ownership to the Administrators group and then gave administrators full persmissions.

Once that is done you should be able to copy the missing folder into the FileRepository directory.

Next try to apply the update again and in my case it worked.

Windows10Update Success

VN:F [1.9.22_1171]
Rating: 10.0/10 (2 votes cast)

Categories: Uncategorized, Windows Forms Tags:

Tricks to setting up WCF Service hosted on IIS

February 17th, 2016 No comments

The following is a short checklist of items to consider when trying to deploy a WCF Service to an IIS server.

These instructions are for a windows server box

  1. Ensure that you have the required level of .Net installed first
  2. Install the following roles – Application Server / Web Server and choose all the default options when prompted
  3. Check the ISAPI and CGI Restrictions and ensure .net framework 4.0.3 is installed and set to allowed
  4. If not you need to open a cmd window and go to c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ and run “aspnet_regiis -i”
  5. My service writes to a log file. Make sure the user that runs the application pool for the website has write access to the folder where the log file will be written

If you need to set up HTTPS then do the following

  1. In IIS Manager on the entire server double-click Server Certificates
  2. Create Self Signed Certificate, give it a name
  3. Create a https binding on a port
VN:F [1.9.22_1171]
Rating: 7.0/10 (1 vote cast)

Categories: Uncategorized Tags:

X509Certificate object c# performance and memory issues alternative – fixed

February 17th, 2016 1 comment

The Problem

For my PatchCleaner product I needed the ability to read the digital certificate off a file, like can be seen on the following tab on the file properties window

msi

I want to read the digital certificate and obtain the contents of the “Subject” Field that is a string formated similarly to an Active Directory OU path.

CN=Microsoft Corporation, OU=MOPR, O=Microsoft Corporation, L=Redmond, S=Washington, C=US

The Issue

I originally used the X509Certificate and X509ertificate2 objects like so:

 var cert1 = new X509Certificate(_file);
 var cert2 = X509Certificate2.CreateFromSignedFile(_file);

Both of these worked but I noticed that when accessing the certificate on a large file (200+ Mb):

  1. It was very slow
  2. It seemed to use alot of memory

In fact on closer investigation it appears the X509Certificate reads the entire object into memory! I had a file of 800Mb that I opened with X509Certificate2.CreateFromSignedFile(_file), and the memory usage on my application increased by the same 800Mb before releasing once I had read the value!! Not cool!!

The Solution

 
Performance

This image shows a test application that attempts to read a 294mb patch file in 3 different ways, with a 1 sec sleep between calls:

  1. T1 – read the digital certificate by the X509 Certificate
  2. T2 – read the certificate via WinCrypt all content
  3. T3 – my soltuion via WinCrypt with just PK7 content

You can clearly see two large memory spikes for test 1 and 2, but test 3 doesn’t even register.

Below is a full c# code sample.

I based my solution on the following stack overflow article

Get timestamp from Authenticode Signed files in .NET

References

The only extra class you need to import is:

  • System.Secuirty

WinCrypt

This is a copy paste from the stack overflow article:

CertificateHelper

This is my static class that implements two method calls.

  1. GetDigitalCertificateSlow() -This is the version behind T2 above
  2. GetDigitalCertificate() – this is the one you want

These methods were based on the IsTimestamp code in the StackOverflow article, but I have manage to tweak slightly to get superior performance.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: Uncategorized Tags:

Running WCF Service as both HTTP and HTTPS

February 16th, 2016 No comments

When trying to configure a WCF service to run as both a HTTP and HTTPS endpoint there are some differences to consider:

  1. HTTP uses SOAP 1.1
  2. HTTPS uses SOAP 1.2

This can cause issues with how your XML packets need to be generated with different SOAP Headers.

SSL Config

On the IIS Manager under the website there is a tile titled “SSL Settings”.
To run both HTTP and HTTPS ensure “Require SSL” is unticked

Web Config

If you want to allow people to generate a .wsdl file do not forget to set this in the web config in the service behaviours

<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: Uncategorized Tags:

citrix receiver disable add account popup on startup

February 16th, 2016 3 comments

The problem

I recently installed CitrixReceiver 4.4 for windows (on 2 windows 10 pc’s) and now on start up I am always being asked to “Add Account”

The Solution

The solution that worked for me was from the Citrix website

How to Suppress the Add Account Window in Citrix Receiver for Windows

After reading this I found the solution that worked on my x64 bit windows 10, (so I assume will work on 32 bit) was to run this registry entry

  1. Create a text file
  2. Copy/Past the text into it
  3. Save
  4. change the file extension to .reg
  5. Double click and follow the prompts
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Citrix]
"EnableX1FTU"=dword:00000000

The next time you start, no more Add Account window.

VN:F [1.9.22_1171]
Rating: 9.5/10 (4 votes cast)

Categories: Uncategorized Tags:

MVC Razor View escape character

February 13th, 2015 No comments

The Problem

You want to use your model or some code to append a variable inline with a string.
Assume you want to create a URL with a dynamic element like:

http://appserver-dev.domain.com

where -dev will be an appsetting accessed in razor from @Settings.Default.URLSuffix

When you add the @Settings value in like so;

http://appserver@Settings.Default.URLSuffix.domain.com

it treats the @Settings.Default.URLSuffix as a text string, outputting “http://appserver@Settings.Default.URLSuffix.domain.com” not “http://appserver-dev.domain.com” as you were hoping. What is the escape character?

The Solution

@@ is the escape sequence.. so that should be easy..

http://appserver@@Settings.Default.URLSuffix.domain.com

The problem now is it treats the .domain.com as part of the code and is not happy because a string object does not have .domain.com methods.

http://appserver@@Settings.Default.URLSuffix;.domain.com

Add a semi-colon to end the code and that is the problem solved.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: MVC, Uncategorized Tags:

IIS Express and windows authentication

February 13th, 2015 No comments

How to control the IIS Express Authentication settings

To set the windows authentication parameters for you MVC applicaiton there are two ways to do this .

  1. On a per project basis, by going to the properties of the web app, F4, and setting the windows authentication to on or off; or
  2. Globally for the entire computer.
    • go to the following path, %HemePath%\Documents\IISExpress\config
    • edit the “applicationhost.config” file
    • find the line
    • Change the value as required and then save
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: MVC, Uncategorized Tags:

How to activate Windows Server 2012

December 2nd, 2014 No comments

Issue

Windows Server 2012 will not activate when you try to use the UI to activate a license key.

Solution

Open a command prompt and run the following command

slmgr.vbs /ipk <license key>

Where <license key> is your server license.

Press enter and wait about 30 seconds and you should receive a message saying “Installed product key successfully

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: Uncategorized Tags: