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();

Wednesday, January 20, 2010

Problem with varchar(max) via SQL Native Client

Having issue with retrieve data from varchar(max) field. This is turned out a problem with SQL Native Client. Tried to use “SQL Server Native Client 10.0”, with same result.

Than I have to revert back to use “SQL Server” driver, which doesn’t has performance as good as SQL Native Client driver.

Hope Microsoft will fix it some day.

Here is the link of bug reported: https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=467300&wa=wsignin1.0

Sunday, January 17, 2010

How do I fix IE8 not open link problem

I fix the problem by doing following steps:

Quoted from: http://social.answers.microsoft.com/Forums/en-US/InternetExplorer/thread/e312e580-1cbc-496b-8c6b-b69b8535a7bb


Updates: new version script from:

http://iefaq.info/index.php?action=artikel&;cat=42&id=133&artlang=en

Thanks for OnyXxL to provide the solution.

Hi,

I followed a tip given by Pbell on this forum. Originally, it was made to resolve problems on IE8 32 bits when you use a 32 bits OS. I changed "%ProgramFiles(x86)%" var, and now my issue is resolved for IE8 32 bits on my Windows 7 64 bits. Please try it, and tell me if everything work for you.

For Win 7 64 bits :

1 - Create a new notepad document and paste this text :

@echo off
echo.
echo IEREREG Version 1.07 for IE8 27.03.2009
echo by Kai Schaetzl
http://iefaq.info
echo installs and registers (if suitable) all DLLs known to be used by IE8.
echo should only take a few seconds, but please be patient
echo.
REM ******************************
echo registering IE files
REM IE files (= part of setup)
regsvr32 /s /i browseui.dll
REM regsvr32 /s /i browseui.dll,NI (unnecessary)
regsvr32 /s corpol.dll
regsvr32 /s dxtmsft.dll
regsvr32 /s dxtrans.dll
REM simple HTML Mail API
regsvr32 /s "%ProgramFiles(x86)%\internet explorer\hmmapi.dll"
REM group policy snap-in
regsvr32 /s ieaksie.dll
REM smart screen
regsvr32 /s ieapfltr.dll
REM ieak branding
regsvr32 /s iedkcs32.dll
REM dev tools
regsvr32 /s "%ProgramFiles(x86)%\internet explorer\iedvtool.dll"
regsvr32 /s iepeers.dll
REM Symptom: IE8 closes immediately on launch, missing from IE7
regsvr32 /s "%ProgramFiles(x86)%\internet explorer\ieproxy.dll"
REM no install point anymore
REM regsvr32 /s /i iesetup.dll
REM no reg point anymore
REM regsvr32 /s imgutil.dll
regsvr32 /s /i /n inetcpl.cpl
REM no install point anymore
REM regsvr32 /s /i inseng.dll
regsvr32 /s jscript.dll
REM license manager
regsvr32 /s licmgr10.dll
REM regsvr32 /s msapsspc.dll
REM regsvr32 /s mshta.exe
REM VS debugger
regsvr32 /s msdbg2.dll
REM no install point anymore
REM regsvr32 /s /i mshtml.dll
regsvr32 /s mshtmled.dll
regsvr32 /s msident.dll
REM no reg point anymore
REM regsvr32 /s msrating.dll
REM multimedia timer
regsvr32 /s mstime.dll
REM no install point anymore
REM regsvr32 /s /i occache.dll
REM process debug manager
regsvr32 /s "%ProgramFiles(x86)%\internet explorer\pdm.dll"
REM no reg point anymore
REM regsvr32 /s pngfilt.dll
REM regsvr32 /s /i setupwbv.dll (not there anymore!)
regsvr32 /s tdc.ocx
regsvr32 /s /i urlmon.dll
REM regsvr32 /s /i urlmon.dll,NI,HKLM
regsvr32 /s vbscript.dll
REM VML renderer
regsvr32 /s "%CommonProgramFiles%\microsoft shared\vgx\vgx.dll"
REM no install point anymore
REM regsvr32 /s /i webcheck.dll
regsvr32 /s /i /n wininet.dll
REM ******************************
echo registering system files
REM additional system dlls known to be used by IE
REM added 11.05.2006 Symptom: Add-Ons-Manager menu entry is present but nothing happens
regsvr32 /s extmgr.dll
REM added 12.05.2006 Symptom: Javascript links don't work (Robin Walker) .NET hub file
regsvr32 /s mscoree.dll
REM added 23.03.2009 Symptom: Find on this page is blank
regsvr32 /s oleacc.dll
REM added 24.03.2009 Symptom: Printing problems, open in new window
regsvr32 /s ole32.dll
REM mscorier.dll
REM mscories.dll
REM Symptom: open in new tab/window not working
regsvr32 /s actxprxy.dll
regsvr32 /s asctrls.ocx
regsvr32 /s cdfview.dll
regsvr32 /s comcat.dll
regsvr32 /s /i /n comctl32.dll
regsvr32 /s cryptdlg.dll
regsvr32 /s /i /n digest.dll
regsvr32 /s dispex.dll
regsvr32 /s hlink.dll
regsvr32 /s mlang.dll
regsvr32 /s mobsync.dll
regsvr32 /s /i msieftp.dll
REM regsvr32 /s msnsspc.dll #no entry point
regsvr32 /s msr2c.dll
regsvr32 /s msxml.dll
regsvr32 /s oleaut32.dll
REM regsvr32 /s plugin.ocx #no entry point
regsvr32 /s proctexe.ocx
REM plus DllRegisterServerEx ExA ExW ... ?
regsvr32 /s /i scrobj.dll
REM shdocvw.dll hasn't been updated for IE7 and IE8, it still registers itself for the Windows Internet Controls
regsvr32 /s /i shdocvw.dll
regsvr32 /s sendmail.dll
REM ******************************
REM PKI/crypto functionality
REM initpki can take very long to run and is rarely a problem
REM if there are problems with crypto, SSL, certificates
REM remove the three following REMs from the lines
REM echo We are almost done except one crypto file
REM echo but this will take very long, be patient!
REM regsvr32 /s /i:A initpki.dll
REM ******************************
REM tabbed browser, do at the end, why originally with /n ?
regsvr32 /s /i ieframe.dll
REM ******************************
echo correcting bugs in the registry
REM do some corrective work
REM Symptom: new tabs page cannot display content because it cannot access the controls (added 27. 3.2009)
REM This is a result of a bug in shdocvw.dll (see above), probably only on Windows XP
reg add "HKCR\TypeLib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32" /ve /t REG_SZ /d %systemroot%\system32\ieframe.dll /f
REM ******************************
echo all tasks have been finished
echo.
pause

2 - Close all your IE windows and processes.
3 - Save your document on your Desktop by example, with the .bat extension. Right-click on it, and select "Run as administrator".
4 - Test if this tip resolved your issue by openning IE. If you use a Windows 32 bits version, please replace
%ProgramFiles(x86)% by %ProgramFiles% in your .bat file.

OnyXxL