samedi 29 juin 2013

WP7 binding problem: System.MethodAccessException: Attempt to access the method failed

This an easy and simple problem I faced recently but I waste a lot of time to understand it

For me this problem occured with VS2012 and WP7 project! 

So I explained my project was a simple soundboard.
This soundoard is just composed by a ListBox, and the datatemplate is composed by two buttons and one textbox.

When I build the project and I run it to the emulator

  1. It tooks a lot of time to load and run
  2. Buttons and text filed are empty
But in the Xaml and code, every fields are binded correctly.

Just by looking at the output windows, I had this message

"System.Windows.Data Error: Cannot get 'Description' value (type 'System.String') from 'BoardField' (type 'BoardField'). BindingExpression: Path='Description' DataItem='BoardField' (HashCode=84854501); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String').. System.MethodAccessException: Attempt to access the method failed: .BoardField.get_Description()
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
   at System.Reflection.RuntimePropertyInfo.InternalGetValue(PropertyInfo thisProperty, Object obA first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
The program '[247333058] TaskHost.exe: Managed' has exited with code 0 (0x0)."


So, it seems that there is an accesibility problem.. By reading the info coming from this exception. It looks like it came from the class that contains data. Here is the class that cause problem


Code:
class BoardField
    {
        public string Hero { get; set; }
        public string Name { get; set; }
        public string Path { get; set; }
        public string Description { get; set; }
        public string Language { get; set; }
    }

Just by adding the accessor "public" 
Code:
public class BoardField
    {
        public string Hero { get; set; }
        public string Name { get; set; }
        public string Path { get; set; }
        public string Description { get; set; }
        public string Language { get; set; }
    }


So it seems that the for a WP7 project on WS2012 has wrong settings at project start.

Good Work

dimanche 26 mai 2013

MVVM: Intellisense for getting property name - Intellisense afin de retrouver le nom d'une propriete

By using MVVM,

We all know how boring is to write each name of property in the setter. Mistake, Mispelling lead to debugging.

Here is a small extension methond using linq in order to solve this problem:


Code:
using System;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Collections.ObjectModel;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


namespace Refre.Utils
{
    public static class Helper
    {
        public static void Raise<T, P>(this PropertyChangedEventHandler pc, T source, Expression<Func<T, P>> pe)
        {
            if (pc != null)
                pc.Invoke(source, new PropertyChangedEventArgs(((MemberExpression)pe.Body).Member.Name));
        }
    }
}

Now, we can easily use intellisense in order to find property while writting the setter. here is an example:
Code:
 private string btnName;
        /// <summary>
        /// Gets or sets the button drink name.
        /// </summary>
        public string BtnName
        {
            get { return btnName; }
            set 
            {
                if (!object.Equals(btnName, value))
                {
                    btnName = value;
                    PropertyChanged.Raise(this, o => o.BtnName);
                }
            }
        }
Good work

mercredi 15 mai 2013

Visual studio - Blend designer laisse une image fantôme tant qu'on ne compile pas

Bonjour à tous,

Je viens de tomber sur un nouveau soucis.
Il y a  peu de temps, j'ai réinstaller mon PC. Celui-ci comporte 2 GPU; 1 Nvidia puissant et un Intel moins puissant.

En travaillant sur des projets Windows phone, Quand je zoom ou de-zoom, le designer ne se rafraîchissais pas. Une image fantôme appariait


En gros, pour une raison inconnue, VS n'a pas configurer le PC pour que le designer soit pris en charge par la carte NVIDIA.

Pour résoudre ce problème, il suffit d'aller dans le panneau Nvidia: "Manage 3D setting" (hé oui mon Windows est en anglais)


Il faut choisir les executables: 
  • Blend.exe pour Blend
  • Xdesproc.exe pour le designer de visual studio


En relançant, tout devrais revenir en ordre. 

Bon travail à tous !





lundi 1 avril 2013

SQL Server : Autoriser la connexion à distance via SQL management Studio (SMSS) (French)

Bonjour,

On va dire que cet article aura pour but une fonction d'anti-sèche qu'un apport de connaissance.

J'ai souvent eu à travailler sur une base de donnée SQL server (peu importe l’édition) distante. Dans mon dernier projet, j'ai dû me connecter sur mon server via SMSS sur mon pc client et malheureusement j'ai eu un message d'erreur

La solution fut assez simple,  c'est d'enabler et de lancer le SQL brower.

Voici la procédure à suivre :
http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/

Bon travail

mercredi 30 janvier 2013

Windows Phone 8 (WP8) Emulator problems - Virtual switch error (french)

Mise à jour

Bonjour tous,

Suite à cet article, j'ai voulu continuer mon projet WP8. A ma grande surprise, il ne m’était plus possible de lancer l’émulateur WP8!!!

Bon, au lieu de continuer à lutter, je me suis lancer dans une réinstallation de mon Windows 8 (pfffff c'est lourd). Heureusement, Microsoft permet une réinstallation (selon eux) plus aisée sans avoir à utiliser de média (je répété, selon eux)
Voici un article exposant la procédure à suivre.

Apres plusieurs tests, je me rend compte que mon problème vient d'AVAST! 7 internet security.
Pour une raison qui m'est toujours obscure, le firewall bloque toute création de virtual switchs, que ce soit pour WP8 ou pour tout autre machine virtuelle.

Solution

Soit désinstaller Avast! internet security et le réinstaller en supprimant le firewall

Bon travail à tous!

-----------------------------------------------------------------------------------------------

Salut,

Voici un problème sur lequel je suis tombé en voulant tester ma première application WP8.
Je lance l'emulateur, celui-ci me donne plusieurs message d'erreurs:

le 1er



une fois cliqué sur le boutton "retry", une second message s'affiche

Ça prend un peu de temps mais pour finir, j'ai ce troisième message

Impossible donc de déployer mon application sur l’émulateur (génial :-( )


Quelques recherche sur le net et voila les pistes qui m'ont permis de résoudre:

Tout d'abord, vérifiez que vous n'avez pas de connections VPN ou même un autre système de machines virtuelles (VMware par exemple) si oui, malheureusement, il faudra les désinstaller.

Là, les choses deviennent de plus en plus compliquées:

il y a quelques articles en anglais essayant de guider vers une solution, voici les liens:
http://social.msdn.microsoft.com/Forums/en-US/wptools/thread/1734dac7-37a4-4d9a-bf89-42b6d493adda
http://stackoverflow.com/questions/13149509/windows-phone-8-emulator-error-something-happened-while-creating-a-switch

Mais rien n'a marché.

La solution la plus simple fut de re-installer le SDK WP8 avec la fonction "repair",  tout de même un plantage en fin d’opération.
Mais ça fonctionne.

Rien d’inédits, mais j'y ai quand même passé 4h a tout tester avant de décider de réinstaller. Si ça peut vous permettre d'y passer moins de temps.

Bon travail à tous!




mardi 3 juillet 2012

WCF beginner tutorial

For several years, I was looking for a good WCF tutorial.
I read documentation more or less from the time this technology was released (.NET3.0).

But honestly, I was a bit lost with so many ways to configure everything.
I attend a short training and honestly, at the end I was still "offside".

I start to read great books, but something was still missing

Then, I remember some times ago I found interesting webcasts

The first one is in english
webcast from dasblonde.net
this webcast is complete


The second one is in french and i think it's amazing...
Webcast msdn
Quick, complete, simple but crystal clear.


Good work

lundi 25 juin 2012

Conformity : Silverlight 4 Business application (presentation)


This is a post about an application named conformity made for a company. This app manages any non-appliance on the inbound and outbound material.

I’ll dig into the code later in another post but at this stage, I will just explain how it works.
The technology chosen to create this app is Silverlight in the version 4.

It was quite interesting to use this part of the Silverlight development tool but honestly, as worth it is to develop, as complex it is to deploy when you’re a novice on deployment.

I face some small problem during the development, but one of the dumbest was that it was not possible to interop with Outlook. It’s only possible whether you create an “out-of-browser” Silverlight app. So why not use WPF???

If I had to redo the same app, I rather prefer to play with ASP.NET MVC3 (or 4)

Let’s explain some pictures
The first picture shows only the lay out and the menu.
The layout is the classic template that Microsoft offers when a new SLBA (SilverLight Business Application) start.
SLBA 4 offers a mechanism of user management, easy to use. The user just has to click on the login button. A pop up will appear and the user can login or register if it was not done before.



The second picture shows the one of main windows. Some filter, a grid with all the material listed. A small text field with the reason of the non-compliance.
User can create a new non-compliance by clicking on the “new button” or modify an existing non-compliance.


The third picture shows the same info than the second one, but there is only one point that was added: the button report. Actually, the Client N.C. has to generate report.



The fourth picture shows when user modifies an existing N.C. (non-compliance)



 The fifth picture shows when user adds a new N.C. (non-compliance)

 The sixth picture and seventh shows a preview of a report containing info and status about the N.C.




The eighth picture and nine shows the medication name


And the last one shows the  customer name.


Then now, we will have a look to the code and some bugs and tricks I had to face