mardi 15 juin 2010

Word ne peut pas démarrer le convertisseur mswrd632.wpc

J'ai travaillé avec Interop.Word pour générer les documents Word via une application Winforms.
J'ai récemment fait la migration de la version Office 2003 vers 2007.


Lorsque j'ai ouvert le document généré avec Word 2007, j'ai obtenu l'erreur:
Word ne peut pas démarrer le convertisseur mswrd632.wpc

Après des recherches, cette erreur est due à la mise à jour de sécurité Windows XP, Windows 2000, and Windows Server 2003 au 8 Décembre 2009.


Pour éviter l'affichage de ce message, j'ai supprimé le convertisseur mswrd632 en base de registre. Pour ce faire:
-Exécuter regedit
-Aller dans HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Text Converters\Import\MSWord6.wpc
-Cliquer droit puis supprimer

Cela désinscrit le convertisseur indiqué dans le message d’erreur. Microsoft Office utilisera ses propres convertisseurs pour ouvrir les documents.

Pour plus d'explication:
-http://support.microsoft.com/kb/973904
-http://support.microsoft.com/kb/243088

vendredi 11 juin 2010

L'identité actuelle ([machine]/ASPNET) ne dispose pas d'un accès en écriture à 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files'.

Lors d'une migration du Framework .NET1.1 vers .NET3.5, lorsque je lance une application web, j'ai obtenu un message suivant sur le navigateur:
L'identité actuelle ([machine]/ASPNET) ne dispose pas d'un accès en écriture à 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files'.

La solution la plus facile est d’ajouter à l’utilisateur ASPNET des droits en lecture sur le dossier C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727.

Sinon, lancer aspnet_regiis.exe depuis le dossier C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727. Cette commande permet de mapper l'application à la version ISAPI ASP.NET du Framework 2.0 et exécuter d'autres opérations de configuration.

Les options pour cette commande sont disponibles sur:
http://msdn.microsoft.com/fr-fr/library/k6h9cz8h(VS.80).aspx

jeudi 10 juin 2010

Cyrstal Report "ApplyLogOnInfo" très lent

J'ai migré une application qui utilise Crystal Report qui génère un fichier PDF avec les données de la base SQL Server.

La migration se fait à partir du .NET 1.1 vers .NET3.5.
Depuis la génération du pdf est très lente.
La partie qui est particulièrement lente se trouve dans la boucle:
TableLogOnInfo logOnInfo = new TableLogOnInfo();
for (int i = 0; i < dossierCyrstal.Database.Tables.Count; i++)
{
      //logOnInfo
      logOnInfo.ConnectionInfo.ServerName = [Nom du serveur];
      logOnInfo.ConnectionInfo.DatabaseName = [Nom base de données];
      logOnInfo.ConnectionInfo.UserID = [Nom d'utilisateur];
      logOnInfo.ConnectionInfo.Password = [Mot de passe];
     dossierCrystal.Database.Tables[i].ApplyLogOnInfo(logOnInfo);
}
Après les recherches sur le net, j'ai remplacé la boucle ci-dessous avec deux lignes de code:
      dossierCrystal.DataSourceConnections[0].SetConnection
     ([Nom du serveur], [Nom base de données], [Nom d'utilisateur], [Mot de passe]);
      dossierCrystal.Refresh();

Depuis, la génération s'accélère.

mardi 8 juin 2010

Interopérabilité Word 2007 Un composant externe a levé une exception

J’ai travaillé sur une application Winforms développée en C# qui génère des documents Word.
La génération consiste à remplacer les mots clés dans le document par les données de la base de données.

Sur certains postes d'utilisateur, la génération renvoie une exception:
"Composant externe a levé une exception" ou "Le relais a reçu des données incorrectes"

Après plusieurs recherches, c'est lors d'appel de l'objet Find qui pose problème.
Ceci est dû à l'enregistrement des bibliothèques antérieures à 2007 qui sont enregistrées dans la base de registre Windows après celles de 2007.

Deux solutions possibles:
1. Exécuter la ligne de commande: C:\Program Files\Microsoft Office\Office12\Winword.exe /r qui force la réinscription des dll Word dans la base de registre Windows.
Ou s'il n'y a qu'une seule version Word sur le poste, aller dans Démarrer -> Exécuter -> winword.exe /r

2. Utilisez liaison tardive pour l'objet Find (late binding).
J'ai transformé le code suivant:
object missingValue = Type.Missing;
object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll; Microsoft.Office.Interop.Word.Find find = ThisApplication.Selection.Range.Find;
object texteRecherche = TextRecherche;
object texteRemplace = TextNew;
find.Execute(ref texteRecherche ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref texteRemplace,
ref replaceAll, ref missingValue, ref missingValue, ref missingValue, ref missingValue);
à
object missingValue = Type.Missing;
object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll; Microsoft.Office.Interop.Word.Find find = ThisApplication.Selection.Range.Find;
object texteRecherche = TextRecherche;
object texteRemplace = TextNew;
object[] Parameters;
Parameters = new object[15];
Parameters[0] = texteRecherche
Parameters[1] = missingValue;
Parameters[2] = missingValue;
Parameters[3] = missingValue;
Parameters[4] = missingValue;
Parameters[5] = missingValue;
Parameters[6] = missingValue;
Parameters[7] = missingValue;
Parameters[8] = missingValue;
Parameters[9] = texteRemplace
Parameters[10] = replaceAll;
Parameters[11] = missingValue;
Parameters[12] = missingValue;
Parameters[13] = missingValue;
Parameters[14] = missingValue;
find.GetType().InvokeMember("Execute", System.Reflection.BindingFlags.InvokeMethod, null, find,Parameters);
// Libérer les ressources
System.Runtime.InteropServices.Marshal.ReleaseComObject(oFind);
oFind = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSelection);
oSelection = null;

Le problème a été résolu.

NB: Bien que la première méthode est plus facile, l'application peut échouer par la suite, si la bibliothèque de type Excel 95,… est réinscrite par une autre application ou un service pack.

Pour aller plus loin:
http://support.microsoft.com/kb/313104
http://support.microsoft.com/kb/210565

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