Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i have the conversion code for converting from infopath to HTML

Guid id;
var conversionResults = newItem.Convert(new Guid("853d58f5-13c3-46f8-8b81-3ca4abcad7b3"), Path.GetFileNameWithoutExtension(newItem.Name), null, "Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c", "Microsoft.Office.InfoPath.Server.DocumentConversion", 1, String.Empty, false, true, out id);

Which i got from using the msdn convert http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfile.convert.aspx and general documentation around the subject but whenever i try to run it i get the exception

Could not load type 'Microsoft.Office.InfoPath.Server.DocumentConversion' from assembly 'Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.
   at System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at Microsoft.SharePoint.Administration.SPDocumentTransformDriver.GetTransformProcessor(ExecutingTransformRequest etr)
   at Microsoft.SharePoint.Administration.SPDocumentTransformDriver.Transform(SPWebApplication wa, ExecutingTransformRequest etr)
   at Microsoft.SharePoint.SPFile.Convert(Guid ConverterId, String newFileName, String configInfo, String handlerAssembly, String handlerClass, Byte priority, String peopleToAlert, Boolean sendACopy, Boolean synchronous, Guid& workItemId)
   at RMS.FormServices.ConvertInfopathToASPX(String infopathFile, String fileNamingbasedon) in C:\Documents and Settings\UN\Source Control\Project\FormServices.asmx.cs:line 243

If i change it to

Guid id;
var conversionResults = newItem.Convert(new Guid("853d58f5-13c3-46f8-8b81-3ca4abcad7b3"), Path.GetFileNameWithoutExtension(newItem.Name), null, "Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c", "Microsoft.Office.InfoPath.Server.DocumentConversion", 1, String.Empty, false, false, out id);

it returns success however if i then try

var converted = newItem.GetConvertedFile(id);

it throws a exception and if i try

while (true)
{
    var state = newItem.GetConversionState(new Guid("853d58f5-13c3-46f8-8b81-3ca4abcad7b3"), id);
    if (state == SPFileConversionState.Completed)
        break;
}

then state hits pending, then after a while available state and never changes after that, ive been trying to get this code working for ages and any help would be appreciated

just as a side note, the convert Infopath to HTML is enabled on the sharepoint server, its all configured and it works from sharepoint (very slowly though) i just cant get it working from the code.

Edit: Some futher information after looking at the logs and with the conversion code looking like

var conversionResults = newItem.Convert(new Guid("853d58f5-13c3-46f8-8b81-3ca4abcad7b3"), Path.GetFileNameWithoutExtension(newItem.Name), null, null, null, 1, String.Empty, false, true, out id);

the conversion fails and the following shows up in the logs

08/02/2011 14:53:42.83 Microsoft.Office.Server.Convers (0x04FC) 0x06BC Document Conversions Launcher Service 7jg8 Verbose Calling LoadBalancer.RegisterLauncher
08/02/2011 14:53:42.86 Microsoft.Office.Server.Convers (0x0538) 0x0CBC Document Conversions Load Balancer Service 7jhf Medium RegisterLauncher called with uri http://SEED-DEV8:8082/HtmlTrLauncher
08/02/2011 14:53:42.86 Microsoft.Office.Server.Convers (0x0538) 0x0CBC Document Conversions Load Balancer Service 7jht Verbose LoadList: Add Called: http://SEED-DEV8:8082/HtmlTrLauncher, 0 08/02/2011 14:53:42.86 Microsoft.Office.Server.Convers (0x0538) 0x0CBC Document Conversions Load Balancer Service 7jhu Verbose (note: expected after EnsureLoadBalancerStatus call) register launcher called for uri that's already registered: http://SEED-DEV8:8082/HtmlTrLauncher 08/02/2011 14:53:42.88 Microsoft.Office.Server.Convers (0x04FC) 0x06BC Document Conversions Launcher Service 7jg9 Verbose LoadBalancer.RegisterLauncher succesful 08/02/2011 14:53:42.81 Microsoft.Office.Server.Convers (0x04FC) 0x06BC Document Conversions Launcher Service 7jdv Verbose EnsureLoadBalancerStatus called

Edit 2: i changed the max size for the converter and it is running a lot faster now from both code and sharepoint but the conversion code is still not working and just comming up as failure. the Log for the converter can be found here (everything from the start of the convert code till the end)

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I think the root of the problem is your assembly reference is for the SP2007 Forms Server (i.e. Version=12.0.0.0). I'm not sure there is even a 2010 equivalent, as the DocumentConversion class does not exist in Microsoft.Office.InfoPath.Server, Version=14.0.0.0

You could try not specifying the Assembly and Class (...they are optional and I think primarily used to specify a pre or post conversion handler)...the Conversion Launcher should be able to act on the GUID of the InfoPath Transformer (...which is correct).

So change the Assembly and Class references to null and see if that does the trick.

UPDATE: I set this up in one of my dev environments and it worked without the Assembly or Class arguments:

SPFileConversionResult result = file.Convert(new Guid("853d58f5-13c3-46f8-8b81-3ca4abcad7b3"), "test123", null, null, null, 1, String.Empty, false, true, out id);

One other to check is make sure you have enabled document conversion on your web app: http://technet.microsoft.com/en-us/library/cc770243.aspx. I suspect you have already done this because I don't think you'd be seeing the error, but putting it out there just in case.

share|improve this answer
    
thanks that fixed my original problem but unfortunately the conversionResult is failure, do you know how i can find out why it failed? –  Manatherin Aug 1 '11 at 13:49
    
I'd look in the ULS log (Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS OOB). Should log the error(s) there. –  Rob D'Oria Aug 1 '11 at 13:54
    
it seems to have been spitting out wsstracing.exe (0x0A9C) 0x0AD8 ULS Logging Unified Logging Service uls1 Monitorable Tracing Service lost trace events. Current value 2. all through the conversion but no other items seem to have been logged –  Manatherin Aug 1 '11 at 14:01
    
Go into "Central Admin > Monitoring > Configure diagnostic logging", check the "Document Conversions" category, select "Medium" or "Verbose" from the "Least critical event to report to the trace log" dropdown, and click OK. Try the operation again. –  Rob D'Oria Aug 1 '11 at 14:05
    
Hi Rob, sorry to keep bothering you, ive updated the question with the logs of the converter but i cant work out whats going wrong, would you mind pointing me in the right direction, any help is appreciated –  Manatherin Aug 2 '11 at 14:04
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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