Monday, October 26, 2009

Microsoft Security Essentials and SourceGear Vault

Lately I've been having problems using Source Gear Vault version 4.1.4
I've never had any problem like this with Vault so i started thinking what did I install on the last days. The answer was Microsoft Security Essentials.

I was getting this ugly error message:
Getting latest version of files
Local file update for $/MyFile.cs failed: System.UnauthorizedAccessException: Access to the path 'C:\Users\genwise\AppData\Local\Temp\tmpC692.tmp' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.Delete(String path)
at VCDiff.VCDiff.Apply()
at VaultClientOperationsLib.WorkingFolder.UpdateHiddenFileContentsFromDelta(VaultClientFile file, String deltaFile, Int64 baseVersion, Int64 targetVersion, UInt32 targetCRC, Int64 targetSize)
at VaultClientOperationsLib.UpdateThread.ProcessCommand(UpdateThreadCommand command, UpdateThreadCommandResult& outputResult)


Luckily they guys at Microsoft included a nice option to exclude certain files and folders. Thanks to this I was able to get rid of this problem ( I am not a security export so i hope I didn't open a Pandora Box with this change..)

Sunday, October 11, 2009

IIS 64bits and Oracle 32bits

At the office we have new i7 machines with 64bit OS.
I've spent 2hs to find a solution to this problem so it's worth blogging about it.

I had a DNN site using my own BOLayer which in turn used Oracle (10.2)

I was getting this error on IIS : "the provider is not compatible with the version of Oracle client"

Tried almost everything until I've noticed a nice option in the IIS Application pool advance settings:
"Enable 32-Bit Applications" which weirdly enough was configured as false (default value).





Thursday, October 8, 2009

Google Translate API for .NET 0.3

We use localization in some of our WPF projects and I was wondering how easy would be to integrate the Google Translate API. I must say it has been unbelievable easy to use it! Check the code below:


using Google.API.Translate;
using NUnit.Framework;
 
namespace GoogleTranslation
{
    [TestFixture]
    public class GoogleTransationFixture
    {
        [Test]
        public void TranslateTest()
        {
            var client = new TranslateClient("test");
            var result  = client.Translate("casa", Language.Spanish, Language.Dutch);
            Assert.IsNotEmpty(result);
            Assert.AreEqual("huis", result);
        }
    }
}

Thursday, February 26, 2009

Creating RibbonTab programatically

I've spent several hours on this issue so it's worth document it just in case it might help someone out there...

When using CWPF (aka Prism) in combintation with the RibbonControlsLibrary I was having a weird problem that my RibbonTabs created "inside" the Prism Modules where loosing it's bindign context and therefore the icon/text was gone (the 2nd time).


Both  Bartek Szafko and Joachim Kerschbaumer articles explain very nicely how to create adapter to be able to use RibbonTabs inside CWPF. I am not going to talk about that in this entry so please read them before in case you are just starting with the RibbonControlsLibrary .

My problem is that each of the RibbonTabs created inside CWPF IModule is also driven by a ViewModel. 

  public partial class DynamicTab 
    {
        public DynamicTabVM ViewModel { get; private set; }

        public DynamicTab()
        {
            InitializeComponent();
            DataContext = ViewModel= new DynamicTabVM();
        }

The technique of re-attaching the RibbonTab works fine if there is no databinding or it's using static resources.

In my scenario all the RibbonButtons have a Bindingg against an ICommand in the viewModel.
                     
When "switching" between Ribbon Tabs --> the DataContext was gone for the "dynamic" RibbonTab. 

I COULD not solve the problem by changing the binding to RelativeSource. Probably this is because I am new to WPF binding and the IDE (vs.net 2008) does not really help at all here.


      private void AddDynamicTabs()
        {
            //Create the Tab.
            var dynamicTab = new DynamicTab();

            // The tab DataContext is the ViewModel.
            var vm = (DynamicTabVM) dynamicTab.DataContext;

            // Take the included ribbon tab.
            RibbonTab tab = dynamicTab.DynamicRibbonTab;
            
            // Disconnect from container
            dynamicTab.Content = null;

            // Re-assign the DataContext
            tab.DataContext = vm;


            foreach (var group in tab.Groups)
            {
                group.DataContext = vm;

                foreach (var control in group.Controls)
                {
                    if (control is RibbonButton)
                    {
                        (control as RibbonButton).DataContext = vm;
                    }
                    // TODO : Applies to more controls.. We are currently using RibbonButton.
                }
            }

            MyRibbon.Tabs.Add(tab);

            // This is needed to be able to view the NEW tab using the correct Style/Skin.
            MyRibbon.InvalidateVisual();

        }


You can download the Example code.

The example is not actually using CWPF and therefore this code should be included in the Adapter.