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...