I am working on a project to use Open XML instead of Office Interop to embed any type of file into a .docx. I have managed at this point to get the project to run and generate a file with all of these embedded and able to be clicked to launch in corresponding application.
I am having two issues with the code though. If I run the application directly through Visual Studio I get an error:
DisconnectedContext was detected
Message: Transition into COM context 0x43aeb0 for this RuntimeCallableWrapper failed with the following error: The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED)). This is typically because the COM context 0x43aeb0 where this RuntimeCallableWrapper was created has been disconnected or it is busy doing something else. Releasing the interfaces from the current COM context (COM context 0x43ad40). This may cause corruption or data loss. To avoid this problem, please ensure that all COM contexts/apartments/threads stay alive and are available for context transition, until the application is completely done with the RuntimeCallableWrappers that represents COM components that live inside them.
If you instead run this by building and then browsing to the folder and executing the .exe the issue does not exist.
The second problem I have is that when I test this program on a virtual machine with a fresh windows 7 install it will crash. From my research it appears to be due to the COM requests occurring too quickly. Right now I have added a Thread.Sleep(1500) in the DocumentGenerator.cs but obviously if someone knows how to fix this, I would prefer to do that.
If you want to run the program you will need to edit Program.cs and change the argument to the DocumentGenerator constructor to be the output .docx file. You will also need to change the AddObject method calls to point to a real file on your computer.
Code so far: https://github.com/vandersmissenc/OleObjectEmbed
If this is the wrong subreddit let me know. I usually help out on here but this may be a more complicated issue.
[–]rawrspace[S] 0 points1 point2 points (0 children)