0

I have one Document Library in central administration Name "Deployment List" it contains SharePoint Solutions(WSP files). now i want to add and deploy that solution using c# code it already get file and deploy it form Local drive but i want to get that file(WSP file from Document Library). I am using Timer job to deploy that solution Note : Solution are farm solution

my code is as follow :

try
{
    // It give Error below line that "File not Found"
    SPSolution solution = SPFarm.Local.Solutions.Add("http://centraladmin/Deployment List/MySolution.wsp"); 

    Collection selectedWebApps = new Collection();

    SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://localhost:80"));

    selectedWebApps.Add(webApp);

    solution.DeployLocal(true, true);
}
catch
{
}

I get "File not found" exception when i try to add the solution to the farm.

Any idea how to solve this error?

2
  • I can't see what error you mean
    – luccio
    Commented Apr 20, 2013 at 13:04
  • 1
    He has it in a comment on line 3 in the code Commented Apr 20, 2013 at 13:35

2 Answers 2

2

Well you didn't specify an error, but I am guessing it doesn't know what you are talking about when you give it that url.

When you deploy to SharePoint it expects a physical file in a physical location.

I had a similar problem trying to parse the contents of .doc files from the old 2003 Office library.

We ended up downloading the file to the filesystem, processing it, then deleting it from the filesystem. The same would work here and you would maintain the transparency you are looking for.

Download the file to the server filesystem

Deploy the file

Delete the file from the filesystem

1
  • Seems like a nice approach for overcoming the constraint of having to specify a physical path for the file. Commented Apr 20, 2013 at 13:42
1

Your code does not work as the Solution.Add method expects a System.IO.Path, not a Uri. You need to specify a valid Path (UNC, local path, etc.) when using Solution.Add("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.