Sebastian Wojciechowski’s WebLog

.NET Developer

First things you need to know

  1. You can see the list of detected and enabled addins in Outlook in:
    Tools->Options->Other->Advanced Options->COM Add-Ins…
    If there were some error and addin has not been loaded it will be there with unchecked box. This is where you enable disabled addins. When you check addin and click OK - addin will be enabled right away, you don’t have to restart Outlook

  2. If addin prevented Outlook from functioning correctly it will be "hard disabled" and put there:
    Help->About Microsoft Office Outlook->Disabled Items…
  3. When addin fails to load, by default, we don’t see any info about it or the error details. But we can change it!
  • Open command prompt:
    cmd
  • Type:
    set VSTO_SUPPRESSDISPLAYALERTS=0
  • Run Outlook from that command line, should be like this:
    "c:\program files\Microsoft Office\Office11\Outlook.exe"

Now if something fails with addin - you will see it.

This will give you good basic to debug why your addin doesn’t work.
I recently had a lot of problems with it. I thought about sharing it with you so that you don’t have to go through it again :-)
BTW: you won’t find those information on any forums or other pages ;-)

Things to verify

  1. Install all required assemblies to GAC. This gives them full permissions so if it’s something with permissions now it should work. If it does work - check your CAS settings.

  2. Check manifest file. If you played with solution reorganization, changed names of projects, classes - there will be a problem.
    Take a look at the underlined fragments:

    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" manifestVersion="1.0">
      <assemblyIdentity name="Sample.Addin.dll" version="1.0.0.0" />
      <asmv2:entryPoint name="Startup" dependencyName="dependency0">
        <asmv2:clrClassInvocation class="Sample.Addin.OutlookAddin" />
      </asmv2:entryPoint>
      <asmv2:dependency asmv2:name="dependency0">
        <asmv2:dependentAssembly>
          <assemblyIdentity name="Sample.Addin" version="3.2.0.0" publicKeyToken="c45b3b012bedcf43" />
        </asmv2:dependentAssembly>
        <asmv2:installFrom codebase="Sample.Addin.dll" />
      </asmv2:dependency>
    </assembly>

  3. Then take a look at the registry setting in the setup project. Verify all paths.
    Make sure that XXX in keys below are equal to ProgID:
    HKCU/Software/Classes/XXX/CLSID
    and
    HKCU/Software/Microsoft/Office/Outlook/Addins/XXX
  4. Got this:
    "Could not load file or assembly ‘Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies.
    System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies…."

    Yeah, had this too :) Make sure that you don’t have any Office 2007 applications installed on the development machine. I had SharePoint Designer. Uninstall them and reopen solution. Dependency to office.dll 12.0.0.0 should be gone (verify it in the dependency list in setup project).
    Rebuild setup project.

I think that’s it :)
Good luck!

Recently I have been asked this question. Answer is that it cannot be null and will not be null, so you don’t have to:

.Text != null

Why? Because .Text property in base class does:

    set
    {
        if (value == null)
        {
            value = "";
        }
	.....
    }

Above is for TextBox from Windows.Forms, as for TextBox from WebControls it’s the same. The getter looks like this:

    get
    {
        string str = (string) this.ViewState["Text"];
        if (str != null)
        {
            return str;
        }
        return string.Empty;
    }

If you don’t believe me just try to assign a null value :-)

If you do a custom activity, configure it to use Lookup fields on field configured as DesignerType=”StringBuilder” and instead of field value you get [%_x005f_String0%] you need to process this value with this function: public static string ProcessStringField ( string str, Activity activity, WorkflowContext context ) Here is a code sample:

//...
public static DependencyProperty __ContextProperty =
    DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(EmailActivity));
//...
[ValidationOption(ValidationOption.Optional)]public WorkflowContext __Context
{
    get { return (WorkflowContext) base.GetValue(__ContextProperty); }
    set { base.SetValue(__ContextProperty, value); }
}
//...
protected override ActivityExecutionStatus Execute(ActivityExecutionContext provider)
{
    Activity parent = provider.Activity;
    while (parent.Parent != null)
    {
        parent = parent.Parent;
    } 

    string returnValue = Helper.ProcessStringField(stringToProcess, parent, this.__Context));
}

It seems that if you don’t have WorkflowContext you can pass null

string returnValue = Helper.ProcessStringField(stringToProcess, parent, this.__Context));

I recently had this problem. I have a Windows Form that hosts a WebBrowser control. The page in the WebBrowser control closes itself using window.close and when it does that the Windows Form freezes up.

Found a solution here posted by Jeff Sanders on his blog (thanks man!)

The sample code is provided in VB.NET Below is the same code rewritten in C#

public class ExtendedWebBrowser : WebBrowser
    {
        public const int WM_PARENTNOTIFY = 0x0210;
        public const int WM_DESTROY = 2;

        public delegate void ClosingEventHandler();
        public event ClosingEventHandler Closing;

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_PARENTNOTIFY:
                    if (!this.DesignMode)
                    {
                        if (m.WParam.ToInt32() == WM_DESTROY)
                        {
                            if (this.Closing != null)
                            {
                                this.Closing();
                            }
                        }
                    }
                    base.DefWndProc(ref m);
                    break;

                default:
                    base.WndProc(ref m);
                    break;
            }
        }
    }

When I browse code looking for something or when I take a look at a new class I want to see as much code as I can. But then when I enter the “coding” mode I want to focus on code that I write and I want to have bigger font to make it easier to read.

To achieve this you could change the font size in options, well this is what you have to do. But doing it manually is not real.

The simplest solution is to just make font bigger/smaller using a shortcut key. We could write macro for that… wait, hold on… what I see, Visual Studio already has macro for making source code editor font bigger/smaller, sweet– high five!

macros

So the only thing we have to do is just bind shortcut keys to those macros.

I use CTRL+A for making the font bigger and CTRL+Z for making it smaller (just like changing gears in Need For Speed, well just without CTRL key).

So in results we have something like this:

test

The first time the macro is executed it runs slowly, but next calls are fast.

Ups! :-)

virtuallab_error.jpg

If you get:

 “1 error(s) occurred during this session. Click Error Log for details.“

“Not implemented 0×80004001“

 wme_error1.gif  wme_error2.gif

errors while Capture screen, Entire screen using Windows Media Encoder 9 that probably means that you are in multiple monitor mode.

Switch to one monitor mode and it should work.

Older Posts »