SourceControl2 GetBindings returns Library not registered

1

I have a add-in that works in vs2008 and vs2010. It connects to the TFS 2010 and takes information (SourceControlBindings class) about file using its local path

The code is very simple:

var sc = app.DTE.SourceControl as SourceControl2;

and later

static SourceControlBindings GetBinding(SourceControl2 sc, string fileName)
{
    return sc.GetBindings(fileName);
}

in vs 2008 and vs 2010 it works without any problem. But when I'm trying to use the same code in vs2012 I'm getting error

Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))

when accessing any property of object returned with GetBinding

var bindings = GetBinding(sc, filePath);
Log.Debug("server:{0} bindings:{1}", bindings.ServerName, bindings.ServerBinding);

also I have EnvDTE references marked with yellow triangles in the solution explorer and types from those assemblies are not resolved with Goto definition VS command. However, it is when I'm creating addin project with addin wizard. And project is compiled and can be launched (another VS2012 instance is started and breakpoints are hit in the addin source code)

How can I get SourceControlBindings in vs2012? Why EnvDTE references are marked with yellow in my addin project?

Thank you

PS the most strange thing is that debugger shows both ServerName and ServerBinding property values. However exception stack shows exactly on the line with logging

error COMException Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))

stack at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)

at System.Dynamic.ComRuntimeHelpers.CheckIfMissingTypeInfoIsExpected(Int32 hresult, Boolean throwIfMissingExpectedTypeInfo)

at System.Dynamic.ComRuntimeHelpers.GetITypeInfoFromIDispatch(IDispatch dispatch, Boolean throwIfMissingExpectedTypeInfo)

at System.Dynamic.IDispatchComObject.EnsureScanDefinedMethods()

at System.Dynamic.IDispatchComObject.System.Dynamic.IDynamicMetaObjectProvider.GetMetaObject(Expression parameter)

at System.Dynamic.DynamicMetaObject.Create(Object value, Expression expression)

at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)

at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)

at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)

at CallSite.Target(Closure , CallSite , Object )

at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)

at line with logging here

PPS seems that is related to .net 4.5 dynamic feature (have no clue why it is involved). Reverted back to .net 3.5 (as temporary solution)

c#
visual-studio-2012
tfs
add-in
asked on Stack Overflow May 8, 2013 by oleksa • edited May 8, 2013 by oleksa

1 Answer

0

To make it works with .net 4 I've replaced GetBindings call with

Workspace.GetServerItemForLocalItem(FullName)

from Microsoft.TeamFoundation.VersionControl.Client.Workspace class (see http://www.codewrecks.com/blog/index.php/2010/09/13/how-to-get-tfs-server-address-from-a-local-folder-mapped-to-a-workspace/ for details)

answered on Stack Overflow Jul 2, 2013 by oleksa

User contributions licensed under CC BY-SA 3.0