Sample Addin projects don't work with .net 4

May 27, 2010 at 2:41 PM
HI, I recently been looking at the System.Addin namespace and playing around with it to see if it will suit my purposes. I started by looking at two of the samples posted here. AT first they all worked without problems, however when I changed the project target to .Net Framework 4, I started to have problems. If I create an addin that returns a user interface element, if that addin is activated in a seperate process I get a Serialization exception when trying to add the returned FrameworkElement the host control. that is, the following code works when targeting the 3.5 framework but not when targeting the .net 4 framework. AddInProcess ap = new AddInProcess(); ap.Start(); HostView.CustomAddIn c = token.Activate<HostView.CustomAddIn>(ap, AddInSecurityLevel.FullTrust); addins.Add(c); // Exception is thrown here. ((Panel)this.Content).Children.Add(c.GetUI()); The exception is: System.Runtime.Serialization.SerializationException. Message "Invalid type code in stream 'Invalid'" stack trace: Server stack trace: at System.Runtime.Serialization.Formatters.Binary.__BinaryWriter.WriteValue(InternalPrimitiveTypeE code, Object value) at System.Runtime.Serialization.Formatters.Binary.IOUtil.WriteWithCode(Type type, Object value, __BinaryWriter sout) at System.Runtime.Serialization.Formatters.Binary.BinaryMethodReturn.Write(__BinaryWriter sout) at System.Runtime.Serialization.Formatters.Binary.__BinaryWriter.WriteMethodReturn() at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, ITransportHeaders& headers, Stream& stream) at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream) Exception rethrown at [0]: Does anybody know why this is? Thanks
Sep 9, 2010 at 5:58 PM

Hi Rob,


Did you manage to find any solution for this problem? Any hints would be great.





Sep 10, 2010 at 12:19 PM

I found this hotfix for it: