开发者

Running into a .NET COMException with MS Office Interop

I am trying to work with the Windows clipboard and Office Interop in an ASP.NET web application.

Everything works well on my local machine running XP (i have created a Windows application first which ran perfectly well on local machine). Then I have executed it on a server running Windows Server 2003 and it worked there as well.

Then I made a ASP.NET sample project and it worked on my local machine. However when this time I deployed it at the server, after banging my head with permissions, it started 开发者_StackOverflow社区giving me this exception which i have no idea why it is doing this:

System.Runtime.InteropServices.COMException (0x80048240): 
Shapes (unknown member): Invalid request. Clipboard is empty or 
contains data which may not be pasted here. 
at Microsoft.Office.Interop.PowerPoint.Shapes.Paste()

Is the problem with any sort of permissions again on clipboard? If yes, how can I grant appropriate permissions?

I need to copy the exact chart and I am just using example from MSDN website.


This is a long shot, but this article about using the Clipboard class in ASP.NET says that you might need to manually change the ApartmentState for the active thread to STA, to be able to use the clipboard in ASP.NET.

There are a few questions about this subject on Stackoverflow as well:

  • Clipboard.GetText returns null (empty string)
  • in .NET, How do I set STAThread when I’m running a form in an additional thread?
  • Using Clipboard.GetDataObject() from a .Net worker thread.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜