Sunday, April 18, 2010

Blend 4 RC could not load silverlight projects solution

I had just upgrading my Silverlight projects from VS2008 to VS2010, has latest Silverlight tool 4 installed. To support Silverlight 4 project editing, I also installed Blend 4 Release Candidate (RC). The upgrading projects went very smooth, and Silverlight application runs great in VS2010.

However, when I trying to open a XAML file in Blend 4 from VS2010, Blend 4 give a few project not support warning message, and then stop loading projects. I couldn’t find any project files in project tab.

After a few time trying, found an workaround:

  1. - Open solution in blend (nothing showing in project tab)
  2. - Go to “File” => “Close Project” (I am surprising that projects are opened)
  3. - “File” => “Open Project”, navigate you solution file, open it.
  4. - Now it should load all projects for you.


Here is the issue I just reported:

http://social.expression.microsoft.com/Forums/en-US/blend/thread/711fd369-d940-4933-9ba6-3992f9309eab


Hope someone found a better solution or Blend 4 team could fix this bug.

Sunday, April 11, 2010

Visual Studio 2010 offically released

 

Visual Studio 2010 officially released today. However, Silverlight 4 has not been delivered at same time. It will be available later this week.

 

Check out:

http://www.microsoft.com/visualstudio/en-us/

Friday, April 9, 2010

Error message when load assembly in Visual Studio 2010 Silverlight 4 project

Error 1 The "ValidateXaml" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'XXX.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'XXX.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.


A solutions posted by krohling here:

Microsoft Silverlight Media Framework - Discussions - SL4 Support:

Right click on each ***.dll file in Windows Explorer
Uncheck 'Read Only'
Click 'Unblock'

I believe this is because Windows does not initially trust files that you download from the internet.

For additional information about this: http://www.petri.co.il/unblock-files-windows-vista.htm

Friday, February 26, 2010

SQL Server Trigger to tracking last data updates

USE Northwind;
GO
IF
OBJECT_ID ('TableUpdateTrigger','TR'
) IS NOT NULL
DROP TRIGGER TableUpdateTrigger
;
GO

CREATE TRIGGER
TableUpdateTrigger
ON Categories
AFTER INSERT, UPDATE,
DELETE
AS
IF
NOT EXISTS (SELECT * FROM zzzTableUpdates WHERE TableName='Categories'
)
INSERT INTO zzzTableUpdates (TableName, LastUpdate) Values ('Categories', GETDATE
())
ELSE
UPDATE
zzzTableUpdates SET LastUpdate=GETDATE() WHERE TableName=
'Categories'
GO


Monday, February 15, 2010

Tuesday, February 9, 2010

.NET Windows Form - Display the standard DataLink property dialog box as child window of current form

Want to shared some of my experience to use DataLink form to edit database connection string in windows form application.

The hardest part is to set DataLink form as child window of current form. But fortunately, I find a way to set HWnd property to get it solved.

Here is the code:

  1: Public Function GetConnection() As String
  2:     Dim dc As MSDASC.DataLinks = New MSDASC.DataLinksClass()
  3:     Dim oConnection As Object = GetFakeOledbConnectionString(existingConnectionString)
  4:     dc.hWnd = Me.Handle    '//Set parent window to current form    
  5:     If dc.PromptEdit(oConnection) Then
  6:        Return CType(oConnection, ADODB._Connection).ConnectionString
  7:     Else
  8:        Return Nothing
  9:     End If
 10: End Function
 11: 
 12: Private Function GetFakeOledbConnectionString(ByVal str As String) As Object
 13:     If String.IsNullOrEmpty(str) Then
 14:         str = "Integrated Security=SSPI; Persist Security Info=True;Password=1;"
 15:     End If
 16:     If Not str.StartsWith("Provider", StringComparison.OrdinalIgnoreCase) Then
 17:         str = "Provider=SQLOLEDB;" + str
 18:         str = str.Replace("Integrated Security=True", "Integrated Security=SSPI")
 19:         If Not str.ToLower().Contains("Persist Security Info".ToLower()) Then
 20:             str = str.TrimEnd(" ").TrimEnd(";") + "; Persist Security Info=True;"
 21:         End If
 22:     End If
 23:     Dim position As Integer = str.IndexOf("AttachDBFile", StringComparison.OrdinalIgnoreCase)
 24:     If position > 0 Then
 25:         str.Replace("AttachDbFilename=;", "")
 26:     End If
 27:     Dim adoConnection As ADODB._Connection = New ADODB.ConnectionClass()
 28:     adoConnection.ConnectionString = str    
 29:     Return adoConnectionEnd 
 30: Function

Tuesday, February 2, 2010

Silverlight: how to update UI before time comsumming process

 

I was trying to make my Silverlight application to update UI before start a time consuming process. For some reason, I can use put that process in new thread. So I have to implement some technique as following:

 

    this.UpdateLayout(); //I want UI update before start that process

    new Thread(() =>

    {

        Thread.Sleep(100);  //Update UI first

        this.Dispatcher.BeginInvoke(() =>

        {

            //Long time process, which stop UI updates

        });

    }).Start();