Canalblog
Suivre ce blog Administration + Créer mon blog

share Thinking ...

share Thinking ...
  • I am an engineer in computer science. Software building is one of my first passions. I have a little more than 3 professional experience years....I won't let you discover all about me now, let's share here a while, maybe i will provide the help you need.
  • Accueil du blog
  • Créer un blog avec CanalBlog
Publicité
share Thinking ...
15 décembre 2008

New blog home : http://sharethinking.fr.nf

Mon blog déménage à l'adresse suivante : http://sharethinking.fr.nf, je me ferai un plaisir de vous y recevoir ;-) !

My Blog changes Home now....Its new place is : http://sharethinking.fr.nf, then it'll be my plaisure to see you there very soon ;-)

Publicité
Publicité
10 décembre 2008

Stack overflow of DataView object property rowfilter (.NEt framework)

I spent a lot of time to find out why the application pool crashs! I finally found out the reason: a stack overflow of DataView object property which is "Rowfilter" of .NET framework. At the begin, of course i did not know. Let's share the resolving way...

I worked on a web application! In its scope, there is a rights management applied to check any element access of the user (like document, product etc...). Then, on my debugging environment (visual studio 2005) i had no failure observed, as on UAT (pre-prod environment). But on the prod environment, when the user already logged tried to access to documents page, we got this error in the event viewer: ("A process serving application pool 'ASPNET2' suffered a fatal communication error with the World Wide Web Publishing Service. The process id was '4104'. The data field contains the error number.")
After five tentatives, the application pool stopped fully with this log in the event viewer: (Application pool 'ASPNET2' is being automatically disabled due to a series of failures in the process(es) serving that application pool.)
Obviously we lost the context and session! then the logout user was forced!

How to resolve it? i tried to find some resolutions ways on the web! But no way :-( ...I tried to reproduced the error on my debugging environment by using the prod database data! But i got no error! First step, i checked with the embedded web server of visual studio and in second step with the IIS server installed on the local machine with always using prod database data replication. But it ran with absolutely no failure.

Then my first deduction is that the problem was not due to the data type and volume of the prod environment. But my question stays available : Why this failure?  Debugging in prod environment requests some specific tools, and i don't have really access to it, almost i am not in charge to do it. But i found out other resolutions ways:

-It could be due to the account NT AUTHORITY / NETWORK which has no enought rights for keys registry access. Microsoft give details here. But it was not my case.

- I saw on the web, It could be due to the code depth. Then i optimized the application by using cache to reduce the database calls, and reduced at the maximum the potential code depthe by rewritting the main part of the page code. This does not resolve the problem.

- Then i have the last solution, by hidding step-by-step the code to find out the code part responsible of the failure! It's really heavy, and not easy as debugging method. But i  did not have any alternative! Then at each step, i deployed the code to dmz website to check the behavior!

I did it until to find out that the affecting rowfilter expression of one dataview with a new value allows to reproduce at any time the failure! I deduced that the rowfilter expression could be the main failure raison! But as i have no error in dev environment, i told to myself that the synthax is surely correct, otherwise i should have to get the failure on my local machine too. Then, by reproducing the scenario on my local machine, i watched this rowfilter expression and did the next remark:
rowfilter expression is too long with a lot of using keyword "OR"..It looks like (ID = 0 OR ID=2 OR ID=3......OR ID=n). Then replacing this expression by (ID IN (0,2,3....n)), i resolved the problem and since the time i get a better performance.

By limiting the n values to around 70 elements, i did no more have the failure. Then my advice is using "IN expression" rather than "OR expresion" in any similar case. You will avoid the stack overflow of dataview property rowfilter











19 novembre 2008

Feedback on Microsoft Event 18/11/08 : Silverlight -Interop - RIA"...

     I was at one of last events of microsoft  which aims to present the capabilities of Silverlight framework.  More precisily it was about the interoperability aspect. There are also an induction to other frameworks RIA which exist and could be really useful, helpful by now, as Silverlight does not include yet all tools to avoid loosing time where the software development is done through a complex architecture like 3-tiers architecture! 
      The chair has been Steve Sfartz, an microsoft architect who works on the silverlight framework developpement. His blog is http://blogs.msdn.com/ssfartz. His was assisted by Pierre during the conference who did the induction of the silverlight controls!

      Before this conference, my knowledge of silvelight was restricted to building "canvas" on Expression blend software, and doing some simple animations 2D as usually done with Flash. Then, my first reflexion is why Microsoft would release out a technology just to do same things like Flash. That's why i was really interested by know more about it.
       Actually, Silverlight is as able as flash! We can do 2D or 3D animations, a lot of fun graphics animations as we usually do with flash. But this is just one of capabilities of Silverlight !

      Silverlight is a crossplatforms(windows, linux, mac) and crossbrowsers(safari, firefox ie) technology like Flash. There is a first version version 1.0 released out since 2007 but which is limited to javascript language. For people like me, who prefers C# or any improved language, we could be happy to know that the last version version 2.0 released out october 2008, include the support of C#, in a world all languages already supported by framework .NET...How is great to know that languages like rubby, python are now supported!! :-) For this first presentation, if you"re interested by a rich interface on your websit, like you have on desktop client sotfwares, silverlight could be a right response!  It's proposed like an middle solution between  heavy client (desktop client ) and light client (browser).

       For the developement environment, if you're from microsoft world like me, you'll need at least 3 tools:
- Visual studio 2008, or express version
- Silverlight tools for Visual Studio
- Expression blend for graphic work!

       For other people, interesting to know that a plugin for Eclipse has been released out and allows to support silverlight developpement for people working with eclipse. It's a really good thing as by this way some people who don't work with visual studio platform, and on other technologies like Java platform could develop silverlight stuff.
Here is the link: http://www.eclipse4sl.org/

A good tool for debugging: http://www.nikhilk.net/Entry.aspx?id=93

 Whatever the developement environment you used to build silverlight application, the solutions is organized into two main projects :
       - Classic web project
       - Silverlight project
    
The output of silverlight project is a zip with the extension "xap" which contains all assemblies. A siverlight project is composed by one or more file ".xaml" and each file associated to behind-code ".xaml.cs" in a separate file.
     Any silverlight application is able to be hosted by any web server (apache or IIS). This is possible as when we try to access to a page containing a silverlight application, this html page will make dowloading the ressource which is "xap" file on client side. THen the silverlight code will be run on the client side.
     Xaml language is structured like any xml file and the current version is xaml 2006. THe next version planned for beginning 2009, will include a new feature : development by "class" way  as did throught traditional POO method.

   To get an experience with the interoperability of silverlight, we did an application which communicate with a REST services Java application hosted by tomcat server. The same application has been able to invoke services hosted on a WCF application with REST style, hosted by IIS server.
   
Silverlight supports three main communication methods:
            - SOAP
            - REST, RSS, ATOM
            - Socket support.

But there are some restrictions due to the fact silverlight is a plugin and crossbrowers:
- GET,POST methods are supported.
- return codes supported 200,404.

Others frameworks have been introduced like  ADO.NET Data services which expose directly via WCF, services to manipulate some datasources ( a set of datatables). RESTLET (http://www.restlet.org/) for java people to implement easily REST.

Cross protocol domains is available since only version 2.0. There is a crossing domain when some ressources are requested by silverlight application on another server! To allow this feature, the file clientaccesspolicy.xml should be available on the partner server, describing the rights.

  About silverlight controls, there are done through 3 aspects now:
- template (by this way you can present a button as a dropdownlist for example)
- style
- behavior
There is a silverlighttoolkit project available on the codeplex server which includes a set of controls ready to be used, like ajaxtoolkit. A multimediaplayer (silverlight control) has been shown allowing to read some videos files with adaptativ streaming format. This is a new format allowing to read a video file and accessing directly to any sequence, without downloading all the video content.

As frameworks RIA, i have to check viewmodel pattern, CSLA NET framework...Don't know enough yet about them.

A good book has been suggested : Data Driven service with silverlight 2 will be released out january 2009. But the chapter 8 is free to download....



30 octobre 2008

les films à voir et revoir!

J'en profite pour faire la promotion d'un blog que j'aime bien!

Si vous aimez parler avions, pilotes etc., voilà un lien sur les films à voir et revoir!

http://machinesvolantes.canalblog.com/

30 octobre 2008

A new movie on red baron life !

Who's red baron? one famous german pilot for the first world war, one of the best ! His real name is Manfred Von RichtHofen....

http://en.wikipedia.org/wiki/Manfred_von_Richthofen

Find below a link in french unfortunaly for english people, which explain who is red baron and how he died...
http://www.tao-yin.com/baron-rouge/

for english people, i found one another link:
http://www.anzacs.net/who-killed-the-Red-Baron.htm

A movie has been released out about 7 months ago in Germany about him:
http://www.redbaron-themovie.com/index_en.html

Publicité
Publicité
30 octobre 2008

2e "Framework Design Guidelines from Cwalina, Abrams" will be released out very soon...

I won't miss to suggest you this book reading :Framework Design Guidelines....It 's from Cwalina, Abrams! I did not design a framework yet! But maybe soon ;-)...Anyway, if you're are really interesting by deisgn patterns and good practices, by avoiding hard coding :-), understanding more easily Fxcop Rules, you found the right book. You could find some notes commented by the leader staff of the team who has been in charge to design FxCop like Brad Abrams or Krzyszrof Cwalina.

These rules are followed through the three versions of framework .NET. They have been implemented through WinFX (next generation of API for windows operating System).

The rules scope the naming convention  of classes,methods, parameters, properties (Pascal and Camel using), good practices of framework design, explanation of patterns used in the framework like IDisposable etc...

From a black box point of view,  it's so easy to say microsoft softwares are not enough reliables as do daily many people, due to a lot of errors resolved after the first release! But please let's avoid to have so wrong ideas about microsoft, you can find here some right reasons!

And one last gift :-) find below a link to the video of  Brad Abrams and Krzysztof Cwalina discussing the 2e of "Framework Design Guidelines":

http://www.informit.com/podcasts/episode.aspx?e=de5a183c-7bb9-4a0e-9499-73b54ae573b6



25 février 2008

Impact du mode debug activée en production - ASP.NET

Pour plus de détails:

http://www.techheadbrothers.com/Astuces.aspx/mode-debug-production

Voici un lien qui explique bien les effets du debug==true dans le web.config, lorsque l'application est déployée en production. Une solution est proposée pour forcer les applications à ignorer ce réglage du web.config. Dans "machine.config", il faut configurer:

<configuration>

  <system.web>

    <deployment retail="true" />

  </system.web>

</configuration>



12 février 2008

bout de code pour charger une arborescence pliante/dépliante representant du contenu XML

Voici un bout de code que je partage avec vous, une fonction qui à partir d'un document xml (xmldocument) charge une treeview correspondant:

la fonction principale de chargement du xmldocument

    

    private void loadTreeview(XmlDocument dom)
        {
            try
            {

                //ici se trouve notre objet treeview
                treeViewConfig.Nodes.Clear();
                treeViewConfig.Nodes.Add(new TreeNode(dom.DocumentElement.Name));
                TreeNode tNode = new TreeNode();
                tNode = treeViewConfig.Nodes[0];

               

                mytools.AddNode(dom.DocumentElement, tNode);
                treeViewConfig.ExpandAll();

            }

             catch (Exception ex)
            {

            }
        }



la fonction AddNode que voici qui est utilisée de façon récursive par la première méthode

   

  public static void AddNode(XmlNode inXmlNode, TreeNode inTreeNode)
        {
            XmlNode xNode;
            TreeNode tNode;
            XmlNodeList nodeList;
            int i;

            // Loop through the XML nodes until the leaf is reached.
            // Add the nodes to the TreeView during the looping process.
            if (inXmlNode.HasChildNodes)
            {
                nodeList = inXmlNode.ChildNodes;
                for (i = 0; i <= nodeList.Count - 1; i++)
                {
                    xNode = inXmlNode.ChildNodes[i];
                    inTreeNode.ChildNodes.Add(GetTreeNodeValue(xNode));
                    tNode = inTreeNode.ChildNodes[i];
                    tNode.NavigateUrl = "javascript:void(0)";
                    AddNode(xNode, tNode);
                }
            }
            else
            {
                   inTreeNode.Text = GetTreeNodeValue(inXmlNode).Text;


               
               
         

            }
        }

12 février 2008

Retour d'expérience installation de l'OpenSuse 10.1 sur dédibox, Smart, SuseFirewall!

Cela fait un moment que je tenais à faire un retour d'expérience de l'installation de l'OpenSuse 10.1 sur la dédibox! En effet j'ambitionnais d'installer un environnement de production sous OpenSuse comme suit:
- apache
- mysql
- Mono pour le support des applications ASP.NET
- subversion
- serveur ftp
- sshd serveur ssh.....

Eh oui, alors séduit totalement par la distributions opensuse 10.3, venant de fedora que je connais depuis quelques années . Je ne dirais pas que l'une est meilleure à l'autre,  faut dire que je conaissais bien fedora surtout pour ses facilités d'administration réseau, un peu comme le sont de toute façon un peu toutes les distributions linux! Bref, c'est l'éternel débat, je m'en passerais, Opensuse a été un vrai coup de coeur, on s'explique par un coup de foudre, voilà par quoi je conclurais!

Bref, j'ai commencé par l'installation de la dedibox, un peu surpris de voir qu'il ne propose que la 10.1, certainement parce qu'elle est le mieux éprouvé! Bref, je me retrousse les manches et j'y vais! Première chose importante qu'il faut noter l'installation est très minimaliste!

1ère etape: Mettre à jour le système
. Pour cela, j'ai du me rabattre sur l'ancêtre dont j'ai toujours su me passer sur la 10.3 grâce à mon magique tool "zypper" qui fait le boulot presque tout seul. "Zypper" n'est pas disponible sur la 10.1, pour cela comme seul utilitaire de disponible, j'avais "YAST". Eh oui, alors à ce moment je ne me doutais pas des difficultés à utiliser "Yast". Certains me diront le contraire, mais j'ai eu beaucoup de mal, j'ai reussi quelques mis à jour, mais il a eu beaucoup de mal à résouldre les dépendances! Bref les mises à jour ont été une petite catastrophe. Désolé pour les "Yasters" :-) mais je m'en passerais bien, comme outil il doit être bien fait, mais la prise en main ne me semble pas du tout évidente. Alors à la recherche d'un outil qui ferait mon bonheur ( vive Linux!), j'ai trouvé enfin mon bonheur! "SMART"! En cherchant un peu sur le net, j'ai enfin eu confirmation que la gestion des packages sur la 10.1 avec Yast a bien été une catastrophe, ainsi  il m'a été conseillé SMART. Je ne regrette pas, il marche super bien. Je vous décris rapidement son installation.

Installation de  SMART:   http://fr.opensuse.org/Smart
   
L'installation de smart nécéssite la présence de 5 packages.

  • python (celui ci aurait dû être installé par défaut,ce qui n'a pas été le cas sur la dédibox)
  • rpm (grâce à celui ci, j'ai installé directement les packages restants)
  • python-xml
  • python-elementtree
  • rpm-python

Pour plus de détails où les trouver:
http://susewiki.org/index.php?title=SMART_Package_Manager#Installing_the_prerequisites

une fois SMART installé, il faut mettre à jour le contenu des repositories en faisant :
- smart update

et enfin pour mettre à jour l'ensemble du système:
- smart upgrade

2ère etape: Installation des composants du système

Je passerai l'installation des différents composants, désolé :-) juste en passant j'ai installé comme serveur bftpd ! Ne pas oublier de désactiver l'accès anonyme (celui de l'utilisateur ftp)!!!

3ère etape: le Firewall

Enfin la maison bâtie, il est temps de restreindre l'accès! Iptables est bien disponible mais un module plus haut niveau est disponible sous suse qui est SuseFirewall. J'ai encore à apprendre sur ce module, car avec Fedora, je connaissais très bien la manipulation directe de Iptables (Eh oui) ,et ca marchait bien. Pour une première utilisation, je trouve SuseFirewall très simple d'utilisation. Mon unique besoin actuel est d'autoriser un nombre de services précis: (serveur web, sshd, ftpd etc..) pour des connexions venant de l'extérieur. L'approche me semble simple, il identifie trois zones:
-  Reseau extérieur
- Réseau intérieur
- Zone démilitarisée (DMZ)

le paramètre FW_DEV_EXT permet de spécifier l'interface connecté au réseau extérieur et FW_DEV_INT celui du réseau local.

Pour ce qui m'intéresse ici c'est le réseau extérieur, comment spécifier les services qui vont être disponibles? C'est grâce aux paramètres du fichier de configuration:
- FW_SERVICES_EXT_TCP
- FW_SERVICES_EXT_UDP

mes services sont disponibles en UDP et TCP. ALors il faut juste modifier comme suit:
FW_SERVICES_EXT_TCP = "80 sshd"
pour autorisier les services web et sshd. Ceci devra être répliqué pour l'UDP.

Le fichier de configuration est à :
/etc/sysconfig/SuSEfirewall2

Une fois vos modifications faites, il faut arrêter redemarrer le service en faisant:
rcSuseFirewall restart



Et voilà ca y est fait!!! J'espère vous avoir aidé!

6 février 2008

Equivalent de "cascade constraint" à la Oracle, en SQL server!

astuce pour supprimer une table référenciée par des contraintes étrangères sous SQL SERVER:

Juste pour partager ce script que je viens d'écrire que j'ai testé  et qui répond à un besoin interessant, celui de pouvoir supprimer une table sous sql server, dont des colonnes sont susceptibles d'être référenciées par des clés étrangères d'autres tables.

Sous oracle c'est super simple : drop table 'tablename" cascade constraint

Mais sous sql server, l'équivalent de la syntaxe n'existe pas :-(. Bien entendu, l'option 'on delete cascade' permet de résoudre partiellement le problème. Dans tous les cas la référence existant, il sera impossible de supprimer la table référenciée. Pour cela, il suffit d'appeler cette procédure dans un premier temps qui supprimera toutes les références , en préservant vos données dans les tables concernées. Et enfin dans un second temps vous pourrez supprimer la table référenciée.

CREATE procedure [dbo].DeleteTableReferences (@database VARCHAR(50),@table nvarchar(50))
as
BEGIN

declare @schema nvarchar(128), @resultConstraints int,@tbl nvarchar(128), @constraint nvarchar(128)
DECLARE @sql nvarchar(255)
declare cur cursor fast_forward for
select distinct cu.constraint_schema, cu.table_name, cu.constraint_name
from information_schema.table_constraints tc
join information_schema.referential_constraints rc on rc.unique_constraint_name = tc.constraint_name
join information_schema.constraint_column_usage cu on cu.constraint_name = rc.constraint_name
where tc.constraint_catalog = @database and tc.table_name = @table
open cur
fetch next from cur into @schema, @tbl, @constraint
while @@fetch_status <> -1
begin
select @sql = 'ALTER TABLE ' + @schema + '.' + @tbl + ' DROP CONSTRAINT ' + @constraint
exec sp_executesql @sql
fetch next from cur into @schema, @tbl, @constraint
end

close cur
deallocate cur

END


Exemple:

On a une table TAB1 referencié par TAB2:

create table TAB2 (
    client_id int not null references TAB1 (client_id),
    groups_id int not null);

impossible de supprimer de TAB1, à cause de la référence définie par TAB2. De plus, cette référence n'est pas nommée donc impossible de la supprimer explicitement. Pour ce faire

DECLARE @RC int
DECLARE @database varchar(50)
DECLARE @table nvarchar(50)
-- Set parameter values
EXEC @RC = [PortfolioModule].[dbo].[DeleteTableReferences ] 'PortfolioModule', 'TAB1 '
drop table TAB1

Publicité
Publicité
1 2 > >>
Publicité