1

I have a workflow that uses a custom dll that I built. I have placed the dll into Inetpub website bin folder.

custom dll has 2 classes XMLUtilities now refferd to as xml Sharepoint helper now refered to as sharepoint

xml has a function called xml to dictionary wich takes a xmlfile and converts it to a string, string dictionary now refered to as xml function.

sharepoint has a function called getdocumentset now refered to as sharepoint function

xml function has only got generic c# dependencies sharepoint funciton has dependencies on Microsoft.Office.DocumentManagement.DocumentSets

here are the function as mentioned above

xml function

/// <summary>
/// DeSerializes a Serialized Dictionary
///<Dictionary>
///<Property Key="">Value</Property>
///<Property Key="">Value</Property>
///<Property Key="">Value</Property>
///<Property Key="">Value</Property>
///</Dictionary>
/// </summary>
/// <param name="xmldata"></param>
/// <returns></returns>
public static Dictionary<string, string> XmlToDictionary(string xmldata)
{
    string key = null;
    string value = null;
    Dictionary<string, string> dictionary = new Dictionary<string, string>();
    byte[] rawXmldata = Encoding.ASCII.GetBytes(xmldata);
    MemoryStream stream = new MemoryStream(rawXmldata);
    XmlReader reader = XmlReader.Create(stream);
    while (reader.Read())
    {
        if (reader.Name.Equals("Dictionary") )
        {
            continue;
        }
        if (reader.NodeType == XmlNodeType.Element)
        {
            key = reader.GetAttribute(0);
        }
        if (reader.NodeType == XmlNodeType.Text)
        {
            value = reader.Value;
        }
        if (key == null || value == null)
        {
            continue;
        }
        dictionary.Add(key, value);
        key = null;
        value = null;
    }
    return dictionary;
}

sharepoint function

public static DocumentSet GetDocumentSetByPath(SPWeb web, string path)
{
    SPFolder folder = web.GetFolder(path);
    return DocumentSet.GetDocumentSet(folder);
}

the calling method code is:

private void DocSetExists_Execution(object sender, ConditionalEventArgs e)
{
        DocumentSet docSet = SharepointHelper.GetDocumentSetByPath(workflowProperties.Web, path);
        if (docSet == null)
        {
            e.Result = false;
        }
        else
        {
            e.Result = true;
        }
}

I have tried with elevated privlages

private void DocSetExists_Execution(object sender, ConditionalEventArgs e)
    {
        SPSecurity.RunWithElevatedPrivileges(delegate
            ()
        {
            DocumentSet docSet = SharepointHelper.GetDocumentSetByPath(workflowProperties.Web, path);
            if (docSet == null)
            {
                e.Result = false;
            }
            else
            {
                e.Result = true;
            }
        });
    }

when the workflow calls the xml function it works fine when it calls the sharepoint function it throws a Sharepoint security exception

my assumption is that it cannot access the dll for documentsets but I would assume sharepoint to have access to such a dll. any ides ?

1 Answer 1

0

Ok i have solved this issue.

the problem was that the dll was not running under full trust, so you can use any objects other then the SP objects.

if you have deployed your dll to %winroot%\inetpub\wwwroot\wss\VirtualDirectories{port}\bin

you have to add a elemet to the web config file

i opted to use the gacutil to install it Command

gacutil /i {path}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.