SerializationException: Constructor of object with type System.RuntimeType not found

Last post 03-11-2008, 10:20 AM by Melody. 1 replies.
Sort Posts: Previous Next
  •  03-10-2008, 9:57 AM 947

    SerializationException: Constructor of object with type System.RuntimeType not found

    In our object model it is possible to check the type information of columns in a data storage:

    public class Storage
    {
        public Type TypeOfColumn(String ColumnName)
        { get; }
    }

    The proxy is generated without problems but if the method is called at runtime an SerializationException is raised, staing that the constructor of the object with type System.RuntimeType was not not found (sorry, exception text is in german):

    System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. --->
    System.Runtime.Serialization.SerializationException: Der für die Deserialisierung eines Objekts mit dem Typ System.RuntimeType erforderliche Konstruktor wurde nicht gefunden. ---> System.Runtime.Serialization.SerializationException: Der für die Deserialisierung eines Objekts mit dem Typ System.RuntimeType erforderliche Konstruktor wurde nicht gefunden.
                bei System.Runtime.Serialization.ObjectManager.GetConstructor(Type t, Type[] ctorParams)
                bei System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
                --- Ende der internen Ausnahmestapelüberwachung ---
                bei System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
                bei System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
                bei System.Runtime.Serialization.ObjectManager.DoFixups()
                bei Microsoft.VisualStudio.Tools.Applications.SerializableObjectContractFormatter.Deserialize(ISerializableObjectContract deserialize, Type expectedType, TypeInfrastructureManager typeInfrastructureManager)
                bei Microsoft.VisualStudio.Tools.Applications.TypeServices.DeserializeToObject(ISerializableObjectContract contract, Type expectedType, TypeInfrastructureManager typeInfrastructureManager)
                bei Microsoft.VisualStudio.Tools.Applications.TypeServices.ObjectFromContractRemoteArgument(RemoteArgument remoteArg, Type expectedType, TypeInfrastructureManager typeInfrastructureManager)
                bei Microsoft.VisualStudio.Tools.Applications.TypeServices.ObjectFromRemoteArgument(RemoteArgument remoteArg, Type expectedType, TypeInfrastructureManager typeInfrastructureManager)
                bei Microsoft.VisualStudio.Tools.Applications.Internal.ProxyHelpers.PostProcessArguments(Object[] originalArguments, IRemoteArgumentArrayContract remoteArguments, ParameterInfo[] remoteArgumentInfo, RemoteArgument remoteRetval, Type remoteRetvalInfo, TypeInfrastructureManager typeInfrastructureManager)
                bei Microsoft.VisualStudio.Tools.Applications.RemotePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
                bei System.Reflection.PropertyInfo.GetValue(Object obj, Object[] index)
                bei Storage.get_TypeOfColumn(String ColumnName)

    As System.Type is part of mscorlib I expected it will be marshalled automatically into the addin without further effort. Is it possible to use System.Type as Parameter or Property with addins?
  •  03-11-2008, 10:20 AM 951 in reply to 947

    Re: SerializationException: Constructor of object with type System.RuntimeType not found

    Thorsten,

       You are using VSTA v 1 correct?  When I tried to pass a type (return typeof(int);) I got the message:  "The constructor to deserialize an object of type 'System.RuntimeType' was not found." 

    This does not work in VSTA v 1- System.Type will not pass through the proxy layer. 
    This works in the VSTA v 2 beta release (I can send you sample code if you like). 

    What are you planning on doing with the type once it is passed to the proxy?  If I have a better idea of what you're goal with this is I could suggest a work around for v 1 or do further testing with v 2.

    >Are there benefits to change to VSTA CTP v2?
    Between VSTA v 1 and VSTA v 2 the proxy changed dramatically- many things that didn't work in v 1 do work in v 2. 

    >I'm still using the .Net Framework 2.0 with Visual Studio 2005 and I expect some effort in switching to .Net 3.5, Studio 2008 and VSTA v2.
    .Net 3.5 is a prereq- VSTA uses 3.5 assemblies.  With Visual Studio 08 you can target the 2.0 framework instead of the 3.5 which would minimize the migration efforts.   Also, Visual Studio 2008 is recommended but not required.  You can opt to use Visual Studio 2005 instead- check out Using VSTA v 2 with Visual Studio 2005

View as RSS news feed in XML