Thursday, April 4, 2013

How to register 32 bit DLL to 64 bit in Win 7?


Use following simple steps to register 32 bit Dll in 64bit operating system.

1. Copy MyDll.dll to “c:\windows\sysWOW64\”
2. Run command prompt as administrator
3. Reach to "sysWOS64" directory by “cd c:\windows\sysWOW64\” command
4. Run “regsvr32 MyDll.dll” in command prompt

Wednesday, March 27, 2013

The calling thread must be STA, because many UI components require this. in WPF.


I faced this issue while opening my window in WPF application.  After spending some hour on Google found I got this work around.

[STAThread]
        public void ShowPopuWindow()
        {
            try
            {
                Thread _Worker = new Thread(DisplayIncommingCallPopup);
                _Worker.SetApartmentState(ApartmentState.STA);
                _Worker.Start();
                _Worker.Join();
            }
            catch (Exception ex) {MessageBox.Show(ex.Message);}
        }

        public void DisplayIncommingCallPopup()
        {
            try
            {
                CallPopupWindow callPopupWindow = new CallPopupWindow();
                callPopupWindow.ShowDialog();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }

How to find Main method in WPF application.


Thursday, May 31, 2012

Formatting Date column of WPF XamDataGrid


xmlns:igEditors="http://infragistics.com/Editors"
xmlns:sys="clr-namespace:System;assembly=mscorlib"

 <Style TargetType="{x:Type igEditors:XamTextEditor}" x:Key="TheDateStyle">
        <Setter Property="Format" Value="dd/MMMM/yyyy" />
 </Style>


 <igDP:Field Name="CaseDate" Label="Case Date"  Visibility="Visible" Width="*">
                            <igDP:Field.Settings>
                                <igDP:FieldSettings EditAsType="{x:Type sys:String}"
                            EditorType="{x:Type igEditors:XamTextEditor}"
                            EditorStyle="{StaticResource TheDateStyle}" />
                            </igDP:Field.Settings>
                        </igDP:Field>

Integration of Avay IP Office CTI Link in WPF C# Project and Interoperability Issues


In last I was assigned a task of Avay IP Office CTI Link integration in my WPF C# Project by my client. As Avaya provide SDKs in C++ and VB 6.0 only.  So we can use only Wrapper DLL of SDK in our C# or managed code project. As I have already integrated this Click and Dial functionally in my VB 6 project using   VB 6.0 SDK of Avay IP Office CTI Link. So in order to avoid hurdles using C++ code I decided to use my VB6 SDK code as DLLL.
After compiling the DLL in Visual Studio 6.0 on my XP (32 bit machine) , when I tried to add its reference in WPF project in Visual Studio 2010 installed on Window 7 64 bit operating system I faced following different interoperability issues.
  1.        While adding assemble reference directly in studio I faced " rence to '.dll' could not be added. Please make sure that the file is accessible and that it is a valid assembly or COM component.”
  2. While loading assemble by [ImportDlL()] method I faced “Unable to find an entry point named ...in DLL”
  3.  And once I added reference of DLL in project after processing it by TIBLIB utility  I faced "Retrieving the COM class factory for component with CLSID {F87D03A3-E4DB-4CA1-91D3-4B8254A90C03} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REG DB_E_CLASSNOTREG)).”

So in order to avoid all these hurdles and interoperability issues, I finally got the way of doing all this.

  1. Install Visual Studio 6.O on your 64 bit operating system and don’t forget to run studio as Administrator.
  2. Open the Avaya IP Office SDK project
  3. Make its DLL
  4. Open your Visual Studio 2010 run as Administrator
  5. Open your WPF  project in which you want to integrate the DLL
  6. Add reference of Avaya VB DLL  in the project and compile  it
  7. Make the setup of the project
  8. Don’t forget to run setup as run as administrator


All will be fine and no interoperability hurdles. I have even tested the setup on 32 bit machine build on 64biy machine.

Wednesday, May 23, 2012

How to make WPF Text Block under line and change its fore color programmatically in C#


 TextDecoration _textDecorationUderLine = new TextDecoration();
             Pen _pen = new Pen();
            _pen.Brush = new LinearGradientBrush(Colors.Blue, Colors.Blue, new Point(0, 0.5), new Point(1, 0.5));
            _pen.DashStyle = DashStyles.Solid;
            _textDecorationUderLine.Pen = _pen;
            _textDecorationUderLine.PenThicknessUnit = TextDecorationUnit.FontRecommended;
            TextDecorationCollection _textDecorationCollection = new TextDecorationCollection();
            _textDecorationCollection.Add(_textDecorationUderLine);
            tbPreferredPhoneWork.TextDecorations = _textDecorationCollection;
            tbPreferredPhoneWork.Foreground = Brushes.Blue;