C# – “Type is not resolved for member” SerializationException in Connection.get_LocalIP() RESOLVED!

Running a web application in the VS 2008′s built in localhost webserver using a custom IIdentity (but not a custom IPrincipal) that you set to the Thread.CurrentPrincipal using a GenericPrincipal causes an exception begining with “Type is not resolved for member” to be thrown when accessing Microsoft.VisualStudio.WebHost.Connection.get_LocalIP().

To resolve this, for your custom IIdentity class add the Serializable attribute, ComVisible(true) attribute, and make it inherit from MarshalByRefObject.

I don’t know exactly why this works, but it does.

6 Responses to “C# – “Type is not resolved for member” SerializationException in Connection.get_LocalIP() RESOLVED!”

  1. jmorris Says:

    Funny, I just ran into this. It actually happens when you assign the IPrincipal implementation to the Thread.CurrentPrincipal property. Setting the Context.User field is fine, however. It also only failed in my case when I called the Page.ClientScript.GetCallbackEventReference method!

    I tried your suggestion with the ComVisible and deriving from MarshalByRefObject and then ran into trouble with serialization/deserialization using the DataContractJsonSerializer. I stopped short there and just removed the Thread.CurrentPrincipal = principal code, since this is a cassini specific error and I’ll be on IIS next week.

    -Jeff

  2. John1596 Says:

    Very nice site! is it yours too

  3. John1596 Says:

    Very nice site! [url=http://oixapey.com/aqvoxr/2.html]is it yours too[/url]

  4. John1596 Says:

    Very nice site!

  5. metal model cars Says:

    undefined

  6. Julian Says:

    I solved this problem setting the specific property in CallContext to null. In my case I use Remoting to consume Business Objects and this problem happen because the my custom Principal object is put in CallContext. I set null in CallContext thgouh the SetData method ands works.
    The problem happen when calling of Response.Flush();

Leave a Reply