dimanche 31 janvier 2010

An error has occurred while attempting to load Crystal Reports runtime


I was using .NET 1.1 framework and am currently migrating a web application to .NET 3.5 framework using Visual Studio .NET 2008.

I get the Crystal Report Runtime from Visual Studio .NET 2008 installation.

 
I use Crystal Report for PDF generation within the application.

In my application project, I reference dll of Crystal and set "copy local" to true. It works well on my machine.

But when I install the application on Server (Windows Server 2008, IIS7), I get the following error:

An error has occurred while attempting to load the Crystal Reports runtime.
Either the Crystal Reports registry key permissions are insufficient or the Crystal Reports runtime is not installed correctly.
Please install the appropriate Crystal Reports redistributable (CRRedist*.msi) containing the correct version of the Crystal Reports runtime (x86, x64, or Itanium) required.  Please go to http://www.businessobjects.com/support for more information.

If you encounter the above error, maybe the following solution could help.

- Check if Crystal Report Runtime is installed on server.
(If folder C:\Program Files\Common Files\Business Objects\ [version]\managed exists).
Otherwise install Crystal Report Runtime.

You can download Crystal Report Runtime from the following links:
 "CRRedist2008_x86.msi" (for 32bit)
 http://resources.businessobjects.com/support/downloads/redistributables/vs_2008/redist/x86/CRRedist2008_x86.msi


"CRRedist2008_x64.msi" (for 64bit)http://resources.businessobjects.com/support/downloads/redistributables/vs_2008/redist/x64/CRRedist2008_x64.msi

 - Check if Crystal is running on 32 bit server or 64 bit server. Go to your application project (in Visual Studio .NET), right click, and select "Properties".On the Build tab, find the Platform Target combo box. If Crystal runs on 32 bit server, change the Platform Target to x86 instead of Any CPU.

vendredi 22 janvier 2010

Unable to install or run the application. The application requires that assembly EnvDTE Version 8.0.xx be installed in the Global Assembly Cache (GAC) first.

I was working on a Winforms application that used EnvDTE library version 7.0.xx for Visual Studio automation. The application was developed using .NET 1.1 with Visual Studio 2003.

Recently, I was doing a migration of that application to .NET 3.5 with Visual Studio 2008.

I chose to deploy using ClickOnce deployment.

When I installed it on my machine, it worked. But then, I did a test with an end user machine without any Visual Studio .NET installed.
I got the following error:
Unable to install or run the application. The application requires that assembly EnvDTE Version 8.0.xx be installed in the Global Assembly Cache (GAC) first.

Then, I changed all references of EnvDTE 7.0.xx in my application with EnvDTE version 8.0.xx. I deployed it again to an end user machine.
But I still got the following error:
Unable to install or run the application. The application requires that assembly EnvDTE Version 7.0.xx is installed in the Global Assembly Cache (GAC) first.

I spent some time to fix the problem. But then I found an article in MSDN that helped me to solve the problem.
“This error is due to a runtime resolution conflict. The version on EnvDTE that is included with visual studio 2008 is 8.0.xx; but the project’s configuration reference is looking for an earlier version of this assembly, version 7.0.xx.
To fix this problem, you must add a binding redirect for that newer version of EnvDTE to your project’s configuration (.config) file.“

I then added to my App.config file the following configuration inside the “runtime” section.
I am now able to deploy the application to end user machines with success.

To learn more : 
http://msdn.microsoft.com/en-us/library/4eeya3de(VS.80).aspx

lundi 16 novembre 2009

[SQL Server 2008]Login associé à dbo est vide


Lors de la restauration d’une base de données, si le login propriétaire de dbo n’existe pas sur le nouveau serveur, le login associé à dbo est vide.

Nous pouvons modifier le login associé à l'utilisateur dbo avec la commande:

'sp_changedbowner login'

Par exemple, si on souhaite définir sa en tant que dbo sur la base de données nommée TEST :

1. Aller dans SQL Server Management Studio


2. Sélectionner la base de données


3. Cliquer droit puis sélectionner Nouvelle Requête


4. Exécuter la commande sp_changedbowner sa

jeudi 30 juillet 2009

SQL Server 2000 Mettre à jour le contenu d’une colonne du type NTEXT

Ci-dessous le script que j’ai utilisé pour mettre à jour une colonne du type NTEXT.
Le but est de remplacer un texte dans cette colonne.


SET NOCOUNT ON


DECLARE @ptrval binary(16);
DECLARE @offset int;

DECLARE @Cle varchar;
DECLARE @TexteARemplacer varchar; --Texte à remplacer
DECLARE @LenTexteARemplacer int; --Longueur de la chaîne à remplacer
DECLARE @NouveauTexte varchar; --Nouveau texte

SET @Cle = 'cle';
SET @TexteARemplacer = 'Texte à remplacer';
SET @LenTexteARemplacer = LEN(@TexteARemplacer)
SET @NouveauTexte = 'Nouveau texte';

-- Récupérer le contenu de la colonne à mettre à jour
SELECT
@ptrval = TEXTPTR(TEST_COLONNE_LIBELLE)
FROM TEST_TABLE
WHERE
TEST_COLONNE_CLE = ' + @Cle + '

--Récupérer la première position du texte à remplacer dans le libellé
SELECT
@offset = PATINDEX('%'+@TexteARemplacer+'%', TEST_COLONNE_LIBELLE) - 1
FROM TEST_TABLE
WHERE
TEST_COLONNE_CLE = ' + @Cle + '

--Mettre à jour le libellé
WHILE @offset > -1
BEGIN
UPDATETEXT TEST_TABLE.COLONNE_LIBELLE @ptrval @offset @LenTexteARemplacer @NouveauTexte;
SELECT
@offset = PATINDEX('%'+@TexteARemplacer+'%', COLONNE_LIBELLE) - 1
FROM TABLE
WHERE
COLONNE_CLE = ' + @Cle +'
END


SET NOCOUNT OFF

mercredi 29 juillet 2009

IE8 Impossible à débugger un projet web depuis Visual Studio s'il y a déjà IE8 ouvert

IE8 possède une propriété Loosely-Coupled Internet Explorer (LCIE) qui lui permet de s'exécuter sur plusieurs processus actives.

Débugger de Visual Studio n'arrive pas à déterminer sur quel processeur il faut attacher le débuggeur.
Vous pouvez corriger ce problème en désactivant la propriété "process growth" de LCIE.

1. Ouvrir RegEdit
2. Aller sur HKEY_LOCALMACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main
3. Ajouter un dword nommé TabProcGrowth
4. Adjuster TabProcGrowth à 0
5. Redémarrer IE8
Ce problème n'apparaît plus sur Visual Studio 2008.

mardi 28 juillet 2009

Impossible de démarrer le débogage sur le serveur web

J'ai trouvé des explications très complètes pour le message d'erreur : Impossible de démarrer le débogage sur le serveur web lorsqu’on lance un projet web ASP.NET sur Visual Studio .NET.

http://msdn.microsoft.com/en-us/library/aa290100(VS.71).aspx

Pour information, c’est écrit en anglais mais facile à comprendre.

vendredi 10 juillet 2009

sp_help_revlogin Transférer les utilisateurs entre SQL Server 2000 et 2008

Lors d'un projet de migration de base de données SQL Server 2000 vers 2008, j'ai recherché une procédure permettant de transférer les utilisateurs.

J’ai retrouvé un script sur le site laboratoire-microsoft.com, une version de procédure sp_help_revlogin pour SQL server 2005. J’ai essayé de l’exécuter mais j’ai obtenu un message d’erreur suivant :

Serveur : Msg 195, Niveau 15, État 10, Procédure sp_help_revlogin, Ligne 53
'LOGINPROPERTY' n'est pas un nom de fonction reconnu.


J’ai donc continué ma recherche. C’est sur le site de support de Microsoft que j’ai retrouvé la solution.


USE master
GO

IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL
DROP PROCEDURE sp_hexadecimal
GO

CREATE PROCEDURE sp_hexadecimal
@binvalue varbinary(256),
@hexvalue varchar(256) OUTPUT
AS
DECLARE @charvalue varchar(256)
DECLARE @i int
DECLARE @length int
DECLARE @hexstring char(16)
SELECT @charvalue = '0x'
SELECT @i = 1
SELECT @length = DATALENGTH (@binvalue)
SELECT @hexstring = '0123456789ABCDEF'
WHILE (@i <= @length)
BEGIN
DECLARE @tempint int
DECLARE @firstint int
DECLARE @secondint int
SELECT @tempint = CONVERT(int, SUBSTRING(@binvalue,@i,1))
SELECT @firstint = FLOOR(@tempint/16)
SELECT @secondint = @tempint - (@firstint*16)
SELECT @charvalue = @charvalue +
SUBSTRING(@hexstring, @firstint+1, 1) +
SUBSTRING(@hexstring, @secondint+1, 1)
SELECT @i = @i + 1
END

SELECT @hexvalue = @charvalue
GO

IF OBJECT_ID ('sp_help_revlogin') IS NOT NULL
DROP PROCEDURE sp_help_revlogin
GO

CREATE PROCEDURE sp_help_revlogin @login_name sysname = NULL AS
DECLARE @name sysname
DECLARE @xstatus int
DECLARE @binpwd varbinary (256)
DECLARE @txtpwd sysname
DECLARE @tmpstr varchar (256)
DECLARE @SID_varbinary varbinary(85)
DECLARE @SID_string varchar(256)

IF (@login_name IS NULL)
DECLARE login_curs CURSOR FOR
SELECT sid, name, xstatus, password FROM master..sysxlogins
WHERE srvid IS NULL AND name <> 'sa'
ELSE
DECLARE login_curs CURSOR FOR
SELECT sid, name, xstatus, password FROM master..sysxlogins
WHERE srvid IS NULL AND name = @login_name
OPEN login_curs
FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd
IF (@@fetch_status = -1)
BEGIN
PRINT 'No login(s) found.'
CLOSE login_curs
DEALLOCATE login_curs
RETURN -1
END
SET @tmpstr = '/* sp_help_revlogin script '
PRINT @tmpstr
SET @tmpstr = '** Generated '
+ CONVERT (varchar, GETDATE()) + ' on ' + @@SERVERNAME + ' */'
PRINT @tmpstr
PRINT ''
PRINT 'DECLARE @pwd sysname'
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
PRINT ''
SET @tmpstr = '-- Login: ' + @name
PRINT @tmpstr
IF (@xstatus & 4) = 4
BEGIN -- NT authenticated account/group
IF (@xstatus & 1) = 1
BEGIN -- NT login is denied access
SET @tmpstr = 'EXEC master..sp_denylogin ''' + @name + ''''
PRINT @tmpstr
END
ELSE BEGIN -- NT login has access
SET @tmpstr = 'EXEC master..sp_grantlogin ''' + @name + ''''
PRINT @tmpstr
END
END
ELSE BEGIN -- SQL Server authentication
IF (@binpwd IS NOT NULL)
BEGIN -- Non-null password
EXEC sp_hexadecimal @binpwd, @txtpwd OUT
IF (@xstatus & 2048) = 2048
SET @tmpstr = 'SET @pwd = CONVERT (varchar(256), ' + @txtpwd + ')'
ELSE
SET @tmpstr = 'SET @pwd = CONVERT (varbinary(256), ' + @txtpwd + ')'
PRINT @tmpstr
EXEC sp_hexadecimal @SID_varbinary,@SID_string OUT
SET @tmpstr = 'EXEC master..sp_addlogin ''' + @name
+ ''', @pwd, @sid = ' + @SID_string + ', @encryptopt = '
END
ELSE BEGIN
-- Null password
EXEC sp_hexadecimal @SID_varbinary,@SID_string OUT
SET @tmpstr = 'EXEC master..sp_addlogin ''' + @name
+ ''', NULL, @sid = ' + @SID_string + ', @encryptopt = '
END
IF (@xstatus & 2048) = 2048
-- login upgraded from 6.5
SET @tmpstr = @tmpstr + '''skip_encryption_old'''
ELSE
SET @tmpstr = @tmpstr + '''skip_encryption'''
PRINT @tmpstr
END
END
FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd
END
CLOSE login_curs
DEALLOCATE login_curs
RETURN 0
GO

Il s’agit de créer deux procédures stockées nommées sp_hexadecimal et sp_help_revlogin dans la base de données master.


Après avoir créé la procédure stockée sp_help_revlogin, je l’ai exécutée à partir de l'Analyseur de requêtes du serveur SQL Server 2000.
EXEC master.sp_help_revlogin;

La procédure stockée sp_help_revlogin produit des scripts de connexion qui créent des noms d'accès avec le SID et le mot de passe d'origine. J’ai fait copier-coller de la sortie, puis je l’ai exécutée dans l'Analyseur de requêtes du serveur SQL Server 2008.