Sunday, October 16, 2011

Easier asinchronous programming

I had a lot of difficulties developing some extensions for LS applications that uses WCF. As you may know, Silverlight allows only asynchronous calls which makes your development much difficult.

Luckily, Microsoft announced add-on for Visual Studio 2010 called Visual Studio Async CTP. More about it you may find on this blog:

http://blogs.msdn.com/b/csharpfaq/archive/2010/10/28/async.aspx

or on official page:

http://msdn.microsoft.com/en-us/vstudio/async.aspx


Edit: if you are experiencing some difficulties with installation, visit this link: http://weblogs.asp.net/scottgu/archive/2010/11/11/a-few-quick-asp-net-mvc-3-installation-notes.aspx

Thursday, October 13, 2011

LightSwitch + MySQL - nested transactions issue

If you are getting Nested Transactions error when trying to CRUD data located in MySQL database through LightSwitch, apply this hotfix:

http://archive.msdn.microsoft.com/KB2534087/Release/ProjectReleases.aspx?ReleaseId=5714

It helped me.

Solving invalid cross-thread access

If you get this error in your code, try something like this (Credits to Justin Anderson):

add using directive:

using Microsoft.LightSwitch.Threading;

and write your code this way:

Dispatchers.Main.BeginInvoke(() =>
{
    // Your code
    UC a = new UC(parameters);
    a.Show();
});

Custom code on application initialize

To add your custom code on application initizlize (Credits to Justin Anderson):
  • Create Search Screen
  • From the Write Code drop-down, select <ScreenName>_CanRun from the Access Control Methods category. This generates an Application class with the <ScreenName>_CanRun
  • Delete method <ScreenName>_CanRun and add Application_Initialize method

    Add this code in created clas to your check user permission

    partial
    void Application_Initialize()
    {
        //Write your Custom code
    }

  • Delete Search Screen (it is not needed anymore)