Question

I posted an issue on SP Guidance tracker after quite some searching, but I saw several unanswered issues there so I'm trying here as well.

I think I have a very simple Proof Of Concept: a Sandbox 2010 solution, a coded web part asking for a string from a service, a feature receiver registering the service implementation at site level during activation (or install) time.

As soon as I try to get the service instance in web part CreateChildControls, I incur into this System.Runtime.Remoting.RemotingException: Failed to write to an IPC Port: The pipe is being closed. In a previous - more complex - try I was having the same exception but for a Tcp channel protocol violation: expecting preamble,and that was even during feature activation.

From the stack trace, I can see that SPUserCodeApplicationHostAppDomainRef.Execute is looking for a SPResource.GetString, and that causes reflection (?) to kick in with Activator.CreateInstance. From this stems some SPResource_SubsetProxy, which involves some proxy and then an Ipc.IpcClientTransportSink.ProcessMessage follows.

Has anyone met anything like this?

My dev box has Windows 7 64bit, SP Foundation 2010.

Edit

Of course all of this does not happen if I try with a Farm solution (and in feature activation I register mapping at site level with properties.Feature.Parent, instead of properties.UserCodeSite)

Was it helpful?

Solution

Looks like this could be an actual bug. Did you ever get this resolved?

MSHotFix

OTHER TIPS

I know this is an old post, but I was having this exact problem with a custom sandbox web part I am developing and it was a real pain to solve. I believe this is caused when there is a static reference to a SPList or SPListItem object.

A simplified version of the class that was causing this error:

class SomeClass
{
    private SPList List;
    private SPListItem ListItem;

    private static SomeClass _Instance;
    public static SomeClass Instance
    {
        get
        {
            if (_Instance == null) {
                _Instance = new SomeClass();
            }
            return _Instance;
        }
    }

    private SomeClass()
    {
        List = SPContext.Current.Web.GetList("/Lists/SomeList");
        ListItem = List.GetItemById(SPContext.Current.ItemId);
        // other initialisation code.
    }
}

This worked the very first time I loaded the web part, but after that it always errored out with System.Runtime.Remoting.RemotingException: Failed to write to an IPC Port: The pipe is being closed.

Then I changed the class to not store any SPList or SPListItem references:

class SomeClass
{
    private SPList List
    {
        get
        {
            return SPContext.Current.Web.GetList("/Lists/SomeList");
        }
    }
    private SPListItem ListItem
    {
        get
        {
            return List.GetItemById(SPContext.Current.ItemId);
        }
    }

    private static SomeClass _Instance;
    public static SomeClass Instance
    {
        get
        {
            if (_Instance == null) {
                _Instance = new SomeClass();
            }
            return _Instance;
        }
    }

    private SomeClass()
    {
        // other initialisation code.
    }
}

Now the web part works every time. Curiously the first version worked on my local dev box, but failed when I installed it on our staging server.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top