How can I create several instances of Microsoft.Office.Interop.Inf

S

sakito

Hello,

I'm developing an InfoPath Form file export server. I've developed a WCF
service that exposes a single method that is ExportFormToXPS(string fileUri,
string exportedFilePath). Inside the business logic, I'm usign
Microsoft.Office.Interop.InfoPath API. I'd like to cache a pool of
Microsoft.Office.Interop.InfoPath.Application instances, but I see that every
new instance of Microsoft.Office.Interop.InfoPath.Application returns the
same object, which points to the same InfoPath app. Is there a way to create
different instances of the Microsoft.Office.Interop.InfoPath.Application
class? Which is the instance context of
Microsoft.Office.Interop.InfoPath.Application?

------------------
Code Snippet
------------------

Microsoft.Office.Interop.InfoPath.Application ip1 = new
Microsoft.Office.Interop.InfoPath.Application();

Microsoft.Office.Interop.InfoPath.Application ip2 = new
Microsoft.Office.Interop.InfoPath.Application();

int ip1Hc = ip1.GetHashCode();
int ip2Hc = ip2.GetHashCode();

Assert.IsTrue(ip1Hc == ip2Hc); // assert fails because the constructor
return always the same object
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top