I am developing a C# application in which the main application window has a 'tabbed' display, with each tab providing a different feature of the application.
I already have working tabs for a built in web browser, and a 'status' page that displays the status of the connection between the application and a remote server.
I am now trying to add another tab that will act as a 'document reader'.
Before I started trying to add this functionality inside another tab, I wrote a completely separate 'document reader' application, which is fully functioning. My intention is to now 'copy' the C# and XAML from this working standalone document reader into the source for my main application- adding the XAML markup to a 'new tab', and the C# code to the corresponding .xaml.cs
file.
In my standalone document reader application, I was using the MoonPDF library to read the PDF documents, and that was working correctly.
However, after copying the XAML markup, and C# code behind into my existing application, I kept getting DLLNotFoundException
s, even though I had copied all of the DLLs for the external library to the bin
folder of my application.
I tried working through this for a while, but couldn't seem to get it working, so I have decided to revert my changes.
However, when I now try to run my original application, having reverted the changes, I get a XamlParseException
which says:
Exception thrown: 'System.Windows.Markup.XamlParseException' in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'Agent.MainWindow' that matches the specified binding constraints threw an exception.' Line number '5' and line position '5'.
When I 'View Detail' on the exception, and inspect the InnerException
, it says:
{"Retrieving the COM class factory for component with CLSID {...} failed due to the following error: 8007007e The specified module could not be found. (Exception from HRESULT: 0x8007007e).":null}
I can't see the PresentationFramework.dll
file anywhere in my folder structure- is that what the issue is here?
When I Google'd the error, I came across the following question on SO: Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154
The accepted answer on that question suggests that I should check the project properties, that the platform target is set to 'x86'- I have checked, and it is. The other two most 'upvoted' answers suggest that I may be using a 32-bit process or DLL, and so need to build for 'x86'- I am aware that the MoonPDF library that I am using is 32-bit, and so am already compiling/ running my code for 'x86', rather than 'Any CPU'.
Are there any other reasons why I might be getting this runtime error? What else can I do to try and resolve it?