DynamicInvoke exception

Latest post 03-21-2008 5:40 PM by cbsiftcb. 3 replies.
  • 03-20-2008 7:05 PM

    DynamicInvoke exception

     

    I am encountering an exception when attempting to access an object in the host application. The addin uses an interface to access the host object:

    public interface InvoiceInterface

    {

            string invoice { get; }

     

    }

    The host object implements the interface:

    [Serializable]

        public abstract class Invoice : Trade.Interface.TransactionDataManager.Billing.InvoiceInterface

        {

    public string invoice

            {

                get { return _invoice; }

                set { _invoice = value; }

            }

            string _invoice = "";

         }

    public class HostTypeMapProvider : Microsoft.VisualStudio.Tools.Applications.Runtime.ITypeMapProvider

        {

     

            System.Collections.Generic.Dictionary<System.Type, System.String> typeToCanonicalName = null;

            System.Collections.Generic.Dictionary<System.String, System.Type> canonicalToTypeName = null;

     

            internal HostTypeMapProvider()

            {

     

                typeToCanonicalName = new System.Collections.Generic.Dictionary<System.Type, string>();

                canonicalToTypeName = new System.Collections.Generic.Dictionary<string, System.Type>();

     

          

                canonicalToTypeName.Add("Trade.Interface, Trade.Interface.TransactionDataManager.Billing.InvoiceInterface", typeof(Trade.Interface.TransactionDataManager.Billing.InvoiceInterface));

     

                typeToCanonicalName.Add(typeof(Trade.Interface.TransactionDataManager.Billing.InvoiceInterface), "Trade.Interface, Trade.Interface.TransactionDataManager.Billing.InvoiceInterface");

            }

     

            public string GetCanonicalNameForType(System.Type type)

            {

                if (typeToCanonicalName.ContainsKey(type))

                {

                    return typeToCanonicalName[type];

                }

                return null;

            }

     

            public System.Type GetTypeForCanonicalName(string canonicalName)

            {

                if (canonicalToTypeName.ContainsKey(canonicalName))

                {

                    return canonicalToTypeName[canonicalName];

                }

                return null;

            }

        }

    I have successfully passed objects using an interface between the host application and addin, but for some reason I receive an exception on this rather simple implementation.

    Can someone give me a few pointer on other areas to evaluate? Also, the proxy and addin build correctly.

    Thanks.

    [NullReferenceException: Object reference not set to an instance of an object.]
       Microsoft.VisualStudio.Tools.Applications.ExceptionFilterHelper.DynamicInvoke(IExceptionManager mgr, IExceptionNotificationObject exceptionNotificationObject, IRemoteDelegateContract delegateContract, IRemoteArgumentArrayContract remoteArgs, TypeInfrastructureManager typeInfrastructureManager) +119
       Microsoft.VisualStudio.Tools.Applications.DelegateProxy.InvokeDelegate_V_Return(A0 a0) +592
       Microsoft.VisualStudio.Tools.Applications.DelegateProxy.InvokeDelegate_V_NoReturn(A0 a0) +47
       DocumentManager.VSTA.VSTADocumentFieldMapper.ExecuteReadMappingScript(Draw draw, Boolean readOnly, HttpResponse response) in D:\development projects\ddm-winfx-3.5\src\DocumentManager\VSTA\VSTADocumentFieldMapper.cs:79
       DocumentManager.PDF.ManageFDF.BuildFDF(HttpResponse response) in D:\development projects\ddm-winfx-3.5\src\DocumentManager\PDF\CreateDocumentFDF.cs:61
       Trade.docs.FDF.Page_Load(Object sender, EventArgs e) in D:\development projects\ddm-winfx-3.5\src\TradeWeb\docs\FDF.aspx.cs:76
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

     

     

     

  • 03-21-2008 1:20 PM In reply to

    Re: DynamicInvoke exception

    I discovered the problem is because the class is marked [Serializable]. Any idea why this would cause an exception?
  • 03-21-2008 2:57 PM In reply to

    • Gary
    • Top 10 Contributor
    • Joined on 07-13-2006
    • Posts 318

    Re: DynamicInvoke exception

    I'm not sure why...

    Only thought is that the proxy layer's serialization conflicts with this.  I noticed that the sample does something similar with Exception types that require special treatment in the proxy.

    [Serializable]

    public class LocationInvalidException : Exception, ISerializable

    Custom Exception Members Not Generated by ProxyGen.exe

    ProxyGen.exe does not generate proxy code for exception members that are used for serialization, or for any other members that might have executable code. You must define these missing members of the generated proxy exception yourself.

  • 03-21-2008 5:40 PM In reply to

    Re: DynamicInvoke exception

    Thanks.

Page 1 of 1 (4 items) | RSS
Copyright Summit Software Company, 2008. All rights reserved.