Wednesday, March 31, 2010

DTSX - Connection Credentials Management


When you create a DTSX the "Security/Protection Level" property will be set by default to "EncryptSensitiveWithUserKey". Why should you want to know this?

Well, this property means it will encrypt sensitive information with your user credentials. Another thing that is not so explicit about this setting is that all sensitive information will be bound to your machine. Now, this might not be a good idea since most of the time you will not develop in production environment.

In practical terms this means whenever you try to edit or run this dtsx in another machine errors will be raised when you try to read the credentials for the connection to the database.



Error loading mydtsx.dtsx: Failed to decrypt an encrypted XML node because the password was not specified or not correct. Package load will attempt to continue without the encrypted information.

Validation error. Data Flow mydtsx: Connection1 [1]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Connection1" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.

One of the ways to overcome this is to change the property to EncryptSensitiveWithPassword. This way you will be asked to set a password, that will be required to decrypt sensitive information when you run/edit it next time.

e.g. DTEXEC /FILE "C:\MyDTSX.dtsx" /MAXCONCURRENT "-1" /CHECKPOINTING OFF /REPORTING EW /DE MyPassword

TIP: You can set this commad line to run in the scheduled tasks. To set it to run as system account use: NT Authority\System

Friday, March 26, 2010

"Application popup: : "

"Application popup: : " Event ID: 26 can be anything. Basically means a nameless application has thrown a nameless error. After a while the worker application pool process w3wp.exe would throw other events on systems tab like:

"A process serving application pool 'AppPool11' terminated unexpectedly. The process id was '1932'. The process exit code was '0x1'."

"Application pool 'AppPool11' is being automatically disabled due to a series of failures in the process(es) serving that application pool."

"A process serving application pool 'AppPool11' suffered a fatal communication error with the World Wide Web Publishing Service. The process id was '3424'. The data field contains the error number. "

Just for the record, the server was a x64 windows server running among other things .net 1.1 web application.

To cut the story short, we were able to isolate the code that was throwing this error (a third party opensource dll called pdfsharp). The dll would work great as long it was saving/creating pdf, but as soon you tried the .Open command, either passing "stream" or "string to path" when called, the title blank application popup error was thrown only once on the system event viewer (until a reset on the worker was thrown by reseting the iis or killing the process) TIP: You can check the threads on a process with the sysinternals process explorer. In 32bit everything works fine (of course).

Interesting was that the request wouldn't catch that an error occured, meaning the thread would get stuck in the w3wp.exe worker. After a few hung threads (10?) the application pool would stop responding to requests and had to be terminated by the iis as shown.

Thank god we are working with 8 years old technologies, or our life would be pretty boring... not!

Wednesday, March 24, 2010

Process Explorer - Sysinternals

As ferramentas da sysinternals podem não ser novidade para ninguém. Não é por acaso que a empresa que conhecia melhor o Windows que a Microsoft tenha sido comprada pela... Microsoft! Mas nunca é demais realçar os básicos. Vocês vão querer instalar no windows xp o Process Explorer da Sysinternals (que entretanto pelo que percebi começou a ser distribuída com a versão base do windows vista/7).

As potencialidades deste software são imensas. Por exemplo, uma coisa que vocês sempre quiseram saber é a razão porque a vossa máquina está sempre a aceder ao disco... Como saber que programas estão naquele momento a ler/escrever do disco? Em vez de andar a matar processos e a tentar adivinhar basta listar os processos por I/O.

Façam download do programa em http://www.sysinternals.com
"View -> Select Columns -> Process Performance -> I/O Delta"

DICA: "Options -> Replace/Restore Task Manager" substitui o task manager por defeito.

Tuesday, March 23, 2010

Subversion reported an error: 'path' is already a working copy for a different URL

If you want to create a new directory in a subversion server, but the local copy has already been linked to another directory/server you will get this error. Most of the fix for this on the internet will point to use svn commands. This might not be the case, since your old remote directory/server might not be available, and you might be using a client like Ankh where command line implementation is limited.

Ankh will spread a hidden .svn directory in every directory that has been linked with the old remote server/directory. Ankh also creates a ankh.load file in the project root.

The solution is to remove all this .svn directories and ankh.load file. This will make sure your local code will loose link with the old inexistent repository. You can do this by creating a .bat file with the following single line:
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%%G"
The usage is simple:
deletesvn.bat "c:\projects\project1"
(if deletesvn.bat was the name you gave to your batch file and c:\projects\project1 is the root of the directories linked with the old repository)

TIP: Make sure your batch file deleted all .svn directories and you manually deleted the ankh.load file before trying to create a new directory on the new repository.

Wednesday, March 17, 2010

update with inner join in sql server

You cannot update 2 tables at once (you need 2 statements to do that, one for each statement), but you can update with inner joins. The trick is to use the full table name that you want to update, using the keyword "from" before the "where" but after the "set"


E.g.

update table1 set table1.a = x.a, table1.b = ...
from ...... inner join table99 x on x.id = .... and ...
inner join table1 on table1.id = .........
where x.f in (select f ....) and ...

Just mind the bold lettering, the rest is to show you can build complex queries this way.

Warning: the dependency 'file' in project 'project' cannot be copied to the run directory because it would overwrite the reference 'file.'

In Visual Studio 2003 (.net 1.1) you will see this error on your compiler everytime you update the version of a dll on the reference.
The official fix will tell you to add the dll to the GAC, or to make a link to the project (projects -> add reference) instead of linking to a file. If you link a project you can make sure that you recompile the projects from which you depend on. If you put the dll in the GAC, GAC will do version control for you.

The stupid thing about this error though, is that you don't really add version information when you first link the dll, and most times you just want to upgrade the dll version, not keep both of them, so what's the catch?

It seems that this error will occur if you use VS.net dll reference property "copy locally". If you set copy locally to false for each dll referenced and copy them by hand to the bin (or whatever folder you choose under project properties), the error will disapear. The error is misleading since, as far as i can tell, the conflict happens when VS will try to overwrite the file with itself.

I'll buy a coffee to the person that can tell me what is the internal file where VS is recording the referenced dll version information.