Posts

Using the .NET WCF BasicHttpBinding to access a web service using both Client Certificates AND Windows Authentication.

If you're using the WCF BasicHttpBinding to access a web service you may wish to connect using Windows Authentication over HTTPS but also present a client certificate to add an extra layer of security (two factor authentication). The problem is whilst you can add a client certificate it is ignored because settings the ClientCredentialType to Windows means that only Windows authentication is used. BasicHttpBinding basicBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); basicBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; SchedulerAccessWebServiceSoapClient server = new SchedulerAccessWebServiceSoapClient(binding, remoteAddress); server.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindByThumbprint, " be4bca8c388af02ee1c50c3f5f74d6a34fe97daf " ); When you try and access the web service when Require Client Certificates is enabled you see an error similar to this. S...

VMware workstation listening on port 443

Image
When using VMware workstation you may find that VMware workstation is listening on port 443. Running netstat -anb shows the following TCP    0.0.0.0:443            0.0.0.0:0              LISTENING [vmware-hostd.exe] To change this in VMware workstation go to Edit > Preferences > Shared VMs (deprecated) and you can stop sharing here, or disable the port.

Determine which process is using a specific port using PowerShell.

Image
If you find that a process is using a TCP port and you want to know which process is using that port it's easy with PowerShell using the Get-NetTCPConnection and Get-Process cmdlets. # Determine which process is using port 443 $owningProcess = (Get-NetTCPConnection -State Listen -LocalPort 443|SELECT OwningProcess)[0]; $processName = Get-Process -Id $owningProcess.OwningProcess|SELECT ProcessName; Write-Host "Port 443: $($processName.ProcessName)";

The Add Service Reference context menu is missing from Visual Studio and refreshing a service reference displays the error "The current project does not support service references. To enable Windows Communication Foundation support, change the target version of the Microsoft .NET Framework"

Image
 In Visual Studio you notice that the "Add Service Reference" context menu is missing. Refreshing an existing service reference shows the following error "The current project does not support service references. To enable Windows Communication Foundation support, change the target version of the Microsoft .NET  Framework" The solution to this was due to the solution .sln file. Rename the solution file, create a new blank solution and re-add the project. Rebuild and then the system works.

Simple Network Management Protocol (SNMP) is missing from Windows 10 Windows Features in Control Panel

Image
You may find that Simple Network Management Protocol (SNMP) is missing from Windows 10 Windows Features in Control Panel. This is a deprecated feature now however you may still have need of it.  To install this in current versions of Windows 10 goto the modern Settings UI and Add an optional feature Click Add a feature and search for SNMP

Microsoft Visual Studio designer cannot open and reports the error "The designer could not be shown for this file because none of the classes within it can be designed."

I had a problem today whereby I couldn't open the Visual Studio form designer and received the following error viewing any form or user control. The designer could not be shown for this file because none of the classes within it can be designed.  at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)  The solution was to rename the  ProjectAssemblies directory in the appropriate Visual Studio directory and reopen the project. It seems there was some kind o...

Rendering ASP.NET C# CompositeControls and web controls with a tag such as a DIV instead of a SPAN tag.

I've recently had a problem with an ASP.NET composite control where I'd added some specific styles directly to the control. Weirdly .NET (4.6.2 in this case) would take the styles from the SPAN tag of the CompositeControl and apply them to the panels that these custom controls were in. Very strange. The simplest solution is to change the SPAN tag emitted by the CompositeControl to a DIV tag. This can be done by overriding the TagKey property. /// <summary> /// Gets the tag key for the control. /// </summary> protected override HtmlTextWriterTag TagKey {      get { return HtmlTextWriterTag.Div; } }