Tuesday, April 2, 2019

Kitematic - Self Signed Certificate In Certificate Chain

Found this issue while behind a enterprise proxy. Proxy uses self signed certificate. Windows has the certificate as trusted, docker works fine, but Kitematic is having the following issue:

While looking in the web found this article:
https://github.com/docker/kitematic/issues/1633

This solution works:

Basically need to set a variable:

set NODE_TLS_REJECT_UNAUTHORIZED=0

Once that is done open Kitematic it should work

Monday, March 19, 2018

Adding network printer to local machine in Windows.

In Windows, if you choose to share a printer, you can from another machine just navigate and right-click and select "Connect"



Wednesday, November 29, 2017

NodeJS behind proxy

I was getting this message when trying to run node js:

D:\Temp>npm install vss-web-extension-sdk
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "vss-web-extension-sdk"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10
npm ERR! code ECONNRESET

npm ERR! network tunneling socket could not be established, statusCode=407
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! Please include the following file with any support request:
npm ERR! D:\Temp\npm-debug.log

Well I am behind a Corporate enterprise, so I can the following command:

npm config set proxy http://[username]:[password]@[proxyServerAddress]:[proxyPortNumber]
and also ran
npm config set https-proxy http://[username]:[password]@[proxyServerAddress]:[proxyPortNumber]

Notice the same address on the first and second entries, that is normal. Just telling the https traffic to go through the same proxy.

Now I get this:

D:\Temp>npm install vss-web-extension-sdk
D:\Temp
`-- vss-web-extension-sdk@4.125.2
  +-- @types/jquery@3.2.16
  +-- @types/jqueryui@1.11.37
  +-- @types/knockout@3.4.47
  +-- @types/mousetrap@1.5.34
  +-- @types/q@0.0.32
  +-- @types/react@16.0.25
  `-- @types/requirejs@2.1.31

npm WARN enoent ENOENT: no such file or directory, open 'D:\Temp\package.json'
npm WARN MyProject No description
npm WARN MyProject No repository field.
npm WARN MyProject No README data
npm WARN MyProject No license field.


Monday, January 30, 2017

TFS2015 Exception Message: The file "" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.

 Many hours later I find out what was going on with my TFS restore.

 I was trying to restore a TFS2013 backup into a TFS2015 system. I kept getting this error:


Looking into the error log I saw this one line:
Exception Message: The file "<your_backup_database_name>" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.

As it turned out the directory of the <your_backup_database_name> was compressed in the Windows os level so I went and set to not compress anymore:


Hope this helps.

Once the above was done the system restored fine.


Friday, October 3, 2014

How to log yourself off from a remote server from command line on your workstation.

All of this information I got from:
This cool blog

First you must have administrative rights on the machine you are trying to log yourself off of.

You will need to get the SessionId to do that run this command bellow
quser /server:[ServerName]

You will something close to this:
USERNAME  SESSIONNAME  ID  STATE   IDLE TIME  LOGON TIME
[YourId]                2  Disc            3  10/2/2014 12:28 PM


Make a note of the number under the ID column. In this case it is 2.

Next you run the following command using the ID that you got before:
logoff 2 /server:[ServerName]

All done you are logged off.

Tuesday, March 11, 2014

TFS custom enumeration not showing

I have been working with this solution I have 4 projects:
- Project to hold the xaml files
- Project to hold the first level library (contain my custom activities)
- Project to hold Business Layer stuff
- Project to test the Business Layer stuff

Everything was working great.

I had an enumeration that was in the "first level library". It was a parameter in my builds. I noticed a better place for it would be in the Business Layer project instead, so I moved. After I did this I got the following error on my builds:
"Failed to load the following parameters:"

<InArgument x:Key="EnumerationName" x:TypeArguments="enumerationLibrary:EnumerationName" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns=http://schemas.microsoft.com/netfx/2009/xaml/activities">[EnumerationName.DefaultValue]</InArgument>

I would also get the following:

The parameter EnumerationName could not be loaded because the type InArgument<MyNamespace.BLProjectName.EnumerationName> was not found. You cannot edit this parameter, but you can save your build definition without it.

I have already added my TFS folder to the build server's "Version control path custom assemblies" therefore I knew the DLL was in the right place and TFS should see it.

Well then I found this forum entry.

Basically TFS will NOT jump from a xaml workflow file to a DLL that does not have a Activity in it. Since I moved my enumeration to the Business project that project does not have an activity. The solution for this? Add a dummy activity into the project.

Here is an example from Valéry Letroye in the forum above:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Build.Client;
using System.Activities;
 
namespace AG.SCRM.TeamBuild.Helpers
{
 
    //If a custom assembly uses a dependent assembly (reference) which is needed to run activities, 
    //they will not get deployed properly. If this is the case you will get “unknown type” errors on 
    //build definition initialization:
    // TF215097: An error occurred while initializing a build for build definition xxxx: 
    // The type ‘xxxx’ of property ‘xxxx’ could not be resolved.
    //To work around this issue, we add a dummy CodeActivity into the dependent assembly with the
    //class scoped attribute: [BuildActivity(HostEnvironmentOption.All)] 
 
    [BuildActivity(HostEnvironmentOption.All)]
    public sealed class DummyCodeActivity : CodeActivity
    {
        protected override void Execute(CodeActivityContext context)
        {
            throw new NotImplementedException();
        }
    }
}

I did the above and everything started working fine.

God bless,
Bruno

Monday, October 7, 2013

ASPNET user does not have write access to Temporary ASP.NET Files

Issue
Current Identity does not have Write Access to v4.0.30319 Temporary ASP.NET Files

Resolution
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet_regiis.exe -ga domain\user
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Aspnet_regiis.exe -ga domain\user

Friday, September 13, 2013

Getting the dreaded "silverlight.msi" error on install of Visual Studio 2010 SP1

Found this solution at the MSDN KB (KB2608523).

Create a batch file with the following contents, or just run one line at a time on your command prompt. Remember to start your cmd with Admin privileges by right clicking on it.

reg delete HKLM\Software\Microsoft\Silverlight /f
reg delete HKEY_CLASSES_ROOT\Installer\Products\D7314F9862C648A4DB8BE2A5B47BE100 /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\D7314F9862C648A4DB8BE2A5B47BE100 /f
reg delete HKEY_CLASSES_ROOT\TypeLib\{283C8576-0726-4DBC-9609-3F855162009A} /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\install.exe /f
reg delete HKEY_CLASSES_ROOT\AgControl.AgControl /f
reg delete HKEY_CLASSES_ROOT\AgControl.AgControl.5.1 /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00} /f
rmdir /s /q "%ProgramFiles%\Microsoft Silverlight"
rmdir /s /q "%ProgramFiles(x86)%\Microsoft Silverlight"

You will get some errors depending what version of Windows you got (x86 or x64).

After this I re-installed the latest version of Silverlight and all was done.

Friday, July 26, 2013

System.Web.Mobile getting Application_Error throw on .NET 4.0

Just had an strange issue.

User updated ASP.NET page that was created on Visual Studio 2008 to Visual Studio 2010. In the process the project got update to .NET 4.0.

One of the pages was inheriting from System.Web.Mobile, however when we hit this page we would get a message talking about the dll for the System.Web.Mobile was not found or one of its dependencies was not found.

I went inside the project and change it to .NET 3.5 and this fixed the issue.

Now if you need to do .NET 4.0, System.Web.Mobile has been deprecated, so you need to use MVC instead.

Thursday, May 30, 2013

Processor and Memory in Windows 8 System shows "Not Available"

After looking all over the net I found this. It is for Windows Vista, but it does work for the Windows 8 also.

Basically Service account doesn't have enough power to look at the processor and memory. So if you type the following command in a CMD in Administrator mode you can fix this issue.

Step 1 - Press the "Windows" key.
Step 2 - Type "cmd"
Step 3 - Right Click or Long press on the "cmd" application.
Step 4 - On the bottom of the screen you should see "Run as administrator"
Step 5 - On the new command line type in
Net localgroup Administrators Service /add
Step 6 - Restart the machine.
Step 7 - It should be all OK.

Thursday, May 23, 2013

Checking if a DLL is 32bits.

So I was trying to deploy a web service in IIS, but I was getting the following error when I tried to access the service using IE.

"Could not load file or assembly 'myAssembly.name' or one of its dependencies. An attempt was made to load a program with an incorrect format body..."

I had seen this before. My file was inside IIS, so I knew the file was there, so one question remained. I am running pure 64bits, could this dll be compiled in 32bits only? I made the following test.

I went to IIS's "Application Polls" and found my service:


Then I changed the "Enable 32-Bit Applications from FALSE to TRUE.
And the amazing thing is that my service returned XML when I hit it with IIS.

Crap my DLL was really 32bits. But how to really check?

Here comes CorFlags:

By just finding the DLL using command line program for VS2010 (Visual Studio Command Prompt (2010). I normally search for "Prompt" and the program will display.

By running:
CorFlags myLibrary.DLL

The following showed up:
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 11
ILONLY    : 1
32BIT     : 1
Signed    : 1


Just for kicks I ran on another library that I knew was 64bits:
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 9
ILONLY    : 1
32BIT     : 0
Signed    : 1

So I need to go back to my compiler and make sure to compile in 64bits and try again.

God bless,
Bruno

Thursday, April 11, 2013

Microsoft Unity IsRegister is for Debug only

This blog entry is based on this forum discussion, and of course my horrible experience with this.

So here was my code idea.

1 - Start off with an empty container.
2 - Whenever a Interface was asked to be resolved I would look on my current registered interfaces (aka using IsRegistered)
3 - If implementation was found just resolve it.
4 - If implementation was NOT found start looking on current directory for assemblies built by me (my assemblies would start with the company name)
5 - Load assembly and look for classes that implemented the interface I was looking for.
6 - If a specific name of a class was not given I would return the first class that implemented the interface asked.

Great code right? Not really, when running on a multi-threaded system I would get the follow error:

Exception:System.Exception: Collection was modified; enumeration operation may not execute.

So I started looking around and found the article mentioned above. Someone on the thread mentions that IsRegistered should only be used for Debug purpose. And it is NOT thread safe :(

Here is the code posted:

public static bool IsRegistered(this IUnityContainer container, Type typeToCheck, string nameToCheck)
        {
            Guard.ArgumentNotNull(container, "container");
            Guard.ArgumentNotNull(typeToCheck, "typeToCheck");

            var registration = from r in container.Registrations
                               where r.RegisteredType == typeToCheck && r.Name == nameToCheck
                               select r;
            return registration.FirstOrDefault() != null;
        }

The LINQ in there was my issue.

So I resorted to trying to do the register and if throw exception I catch and do my search.



try
{
    newItem = _container.Resolve(interfaceType);
}
catch (ResolutionFailedException)
{
   /// handle it here.

Have fun!

Wednesday, March 20, 2013

ASP.Net (Telerik Controls) page buttons do not respond.

Opportunity:
I had the following page:
The controls in green worked fine and responded to the Calendar event and the Time event, but the buttons in read never went to the code behind.

Looking at the debug information on the Console in Chrome I would get an error with "INVALID JSON PRIMITIVE". Looking on the web gave me no answer.

I moved the End Date with the Start Date controls and the End Date started working, but the Start Date would stop. So it was positional.

Solution:
After much time wasted I found the following line of XMAL in the aspx page that was enclosing all the controls:

<telerik:RadPanelBar runat="server" ID="RadPanelBar1" Width="851px" Skin="Office2007" ClientIDMode="Static" OnClientItemCollapse="PanelCollapse" OnClientItemExpand="PanelExpand">
   <!-- My controls were all in here -->
</telerik:RadPanelBar>

Finally after going back and forth between another page that worked God blessed me with the answer. The ClientIDMode="Static" was the problem.

Explanation:
The root cause was that all my controls ended up having the same ID, so it could not differentiate between the controls and only the first control in the list would work.

That was 1 day worth of working trying to debug this.


Tuesday, February 26, 2013

How to install ASP.Net on your windows machine.

I get sometimes the ASP.NET Not Installed

I just need to run the following command:


\WINDOWS\Microsoft.NET\Framework\<version>\aspnet_regiis -i

Tuesday, February 12, 2013

Getting to see the GAC files

This information comes form this entry.

Inside Visual Studio when I looked at one of my references it was stored in a folder named:
C:\Windows\Assembly\GAC_MSIL\...

But when I tried to navigate to such folder I could not reach it. It told me it does not exist.

Manually navigating to the folder made me even more puzzled. The C:\Windows\Assembly had no folders.

As it turned out I was looking at it using the "CacheViewer" which seems pretty useless. Specially that I could not copy anything out of it, and had no Right-Click actions.

I did the following to correct the issue with the help of the article mentioned above:

1 - Opened my Run command (Windows Key + R)
2 - Typed 'regedit' (without the quotes) 
3 - Pressed enter
4 - Navigated to HKEY_LOCAL_MACHINE\Software\Microsoft\Fusion



5 - Looked for "DisableCacheViewer"
6 - If one is not found right-click on the right pane and select 'New -> DWORD (32-bit) value'

7 - On the new field type in 'DisableCacheViewer'
8 - Double-Click on the entry and type a 1 on the 'Value data:' field

9 - You should be able to go to the C:\Windows\Assembly and see the GAC folders.

God bless,
Bruno

Monday, February 11, 2013

Things to remember when doing replication. Microsoft SQL Server 2008 R2

1 - Remember to have the "Snapshot Agent" running.
  A - Right click on the Publication
  B - Select "View Snapshot Agent Status"
  C - If not running find out why. In my case the service did not have rights to write to a folder, made sure the service did have rights.
  D - Restarted the agent.

2 - Have a substitution to test the Publication.

Wednesday, January 30, 2013

MSSQL I am Admin on the machine. I have the power to be admin in SQL Server installed in the same machine.

Found the attached script in this place.

Create a file with .cmd extension and add these lines bellow:


@echo off
rem
rem ****************************************************************************
rem
rem    Copyright (c) Microsoft Corporation. All rights reserved.
rem    This code is licensed under the Microsoft Public License.
rem    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
rem    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
rem    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
rem    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
rem
rem ****************************************************************************
rem
rem CMD script to add a user to the SQL Server sysadmin role
rem
rem Input:  %1 specifies the instance name to be modified. Defaults to SQLEXPRESS.
rem         %2 specifies the principal identity to be added (in the form "<domain>\<user>").
rem            If omitted, the script will request elevation and add the current user (pre-elevation) to the sysadmin role.
rem            If provided explicitly, the script is assumed to be running elevated already.
rem
rem Method: 1) restart the SQL service with the '-m' option, which allows a single connection from a box admin
rem            (the box admin is temporarily added to the sysadmin role with this start option)
rem         2) connect to the SQL instance and add the user to the sysadmin role
rem         3) restart the SQL service for normal connections
rem
rem Output: Messages indicating success/failure.
rem         Note that if elevation is done by this script, a new command process window is created: the output of this
rem         window is not directly accessible to the caller.
rem
rem
setlocal
set sqlresult=N/A
if .%1 == . (set /P sqlinstance=Enter SQL instance name, or default to SQLEXPRESS: ) else (set sqlinstance=%1)
if .%sqlinstance% == . (set sqlinstance=SQLEXPRESS)
if /I %sqlinstance% == MSSQLSERVER (set sqlservice=MSSQLSERVER) else (set sqlservice=MSSQL$%sqlinstance%)
if .%2 == . (set sqllogin="%USERDOMAIN%\%USERNAME%") else (set sqllogin=%2)
rem remove enclosing quotes
for %%i in (%sqllogin%) do set sqllogin=%%~i
@echo Adding '%sqllogin%' to the 'sysadmin' role on SQL Server instance '%sqlinstance%'.
@echo Verify the '%sqlservice%' service exists ...
set srvstate=0
for /F "usebackq tokens=1,3" %%i in (`sc query %sqlservice%`) do if .%%i == .STATE set srvstate=%%j
if .%srvstate% == .0 goto existerror
rem
rem elevate if <domain/user> was defaulted
rem
if NOT .%2 == . goto continue
echo new ActiveXObject("Shell.Application").ShellExecute("cmd.exe", "/D /Q /C pushd \""+WScript.Arguments(0)+"\" & \""+WScript.Arguments(1)+"\" %sqlinstance% \""+WScript.Arguments(2)+"\"", "", "runas"); >"%TEMP%\addsysadmin{7FC2CAE2-2E9E-47a0-ADE5-C43582022EA8}.js"
call "%TEMP%\addsysadmin{7FC2CAE2-2E9E-47a0-ADE5-C43582022EA8}.js" "%cd%" %0 "%sqllogin%"
del "%TEMP%\addsysadmin{7FC2CAE2-2E9E-47a0-ADE5-C43582022EA8}.js"
goto :EOF
:continue
rem
rem determine if the SQL service is running
rem
set srvstarted=0
set srvstate=0
for /F "usebackq tokens=1,3" %%i in (`sc query %sqlservice%`) do if .%%i == .STATE set srvstate=%%j
if .%srvstate% == .0 goto queryerror
rem
rem if required, stop the SQL service
rem
if .%srvstate% == .1 goto startm
set srvstarted=1
@echo Stop the '%sqlservice%' service ...
net stop %sqlservice%
if errorlevel 1 goto stoperror
:startm
rem
rem start the SQL service with the '-m' option (single admin connection) and wait until its STATE is '4' (STARTED)
rem also use trace flags as follows:
rem     3659 - log all errors to errorlog
rem     4010 - enable shared memory only (lpc:)
rem     4022 - do not start autoprocs
rem
@echo Start the '%sqlservice%' service in maintenance mode ...
sc start %sqlservice% -m -T3659 -T4010 -T4022 >nul
if errorlevel 1 goto startmerror
:checkstate1
set srvstate=0
for /F "usebackq tokens=1,3" %%i in (`sc query %sqlservice%`) do if .%%i == .STATE set srvstate=%%j
if .%srvstate% == .0 goto queryerror
if .%srvstate% == .1 goto startmerror
if NOT .%srvstate% == .4 goto checkstate1
rem
rem add the specified user to the sysadmin role
rem access tempdb to avoid a misleading shutdown error
rem
@echo Add '%sqllogin%' to the 'sysadmin' role ...
for /F "usebackq tokens=1,3" %%i in (`sqlcmd -S np:\\.\pipe\SQLLocal\%sqlinstance% -E -Q "create table #foo (bar int); declare @rc int; execute @rc = sp_addsrvrolemember '$(sqllogin)', 'sysadmin'; print 'RETURN_CODE : '+CAST(@rc as char)"`) do if .%%i == .RETURN_CODE set sqlresult=%%j
rem
rem stop the SQL service
rem
@echo Stop the '%sqlservice%' service ...
net stop %sqlservice%
if errorlevel 1 goto stoperror
if .%srvstarted% == .0 goto exit
rem
rem start the SQL service for normal connections
rem
net start %sqlservice%
if errorlevel 1 goto starterror
goto exit
rem
rem handle unexpected errors
rem
:existerror
sc query %sqlservice%
@echo '%sqlservice%' service is invalid
goto exit
:queryerror
@echo 'sc query %sqlservice%' failed
goto exit
:stoperror
@echo 'net stop %sqlservice%' failed
goto exit
:startmerror
@echo 'sc start %sqlservice% -m' failed
goto exit
:starterror
@echo 'net start %sqlservice%' failed
goto exit
:exit
if .%sqlresult% == .0 (@echo '%sqllogin%' was successfully added to the 'sysadmin' role.) else (@echo '%sqllogin%' was NOT added to the 'sysadmin' role: SQL return code is %sqlresult%.)
endlocal
pause

Tuesday, January 8, 2013

Making a bootable Windows 8 USB drive

Just download "Windows 7 USB/DVD download tool" from Microsoft and follow the directions.


God bless,
Bruno

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt." in normal lines of code.

I am trying to find out what is going on.

I am in VS2012 and getting this error message on a simple assignment. At least on the surface is simple.

On other machines the same code works fine.

The problem was the receiving object was coming from a x86 assembly and the object getting assigned to the property was coming from a x64 assembly. Strange that when I moved the code to the other machine it changed the references to all be x86 references. So I did not crash. Not sure how I could fix this forever.

God bless,
Bruno

Kitematic - Self Signed Certificate In Certificate Chain

Found this issue while behind a enterprise proxy. Proxy uses self signed certificate. Windows has the certificate as trusted, docker works f...