Hosting PreviewHandlers on x64 gives REGDB_E_CLASSNOTREG - com

So this is the case,
I am using the http://www.codeplex.com/C4FDevKit,
I want to use the PreviewHandlerHost control in my desktop application
I successfully been able to do it and test it on XP 32, 64 bits and Vista 32, 64 bits
the issue only appeared on XP x64, This is the exception message
Unable to cast COM object of type
'System.__________ComObject' interface type
'MyApplication.IPreviewHandler'. This
failed because the QueryInterface call
on the COM component for the interface
with IID
'{8895B1C6-B41F-4C1C-A562-0D564250836F}'
failed due to the following error:
class not registered (Exception from
HRESULT: 0x80040154
(REGDB_______E___CLASSNOTREG)).
Please any help is appreciated.
And the file I was trying to preview was a Microsoft Word Document.

Go into the Project Properties for your desktop application, click the "Compile" tab and click "Advanced Compile Options...". Change "Target CPU" to x86, click OK, save, recompile and try again.
I've just hit this one myself - see COMException "Class not registered" on 64-bit Windows for more info.

Related

Retrieving the COM class factory for component with CLSID {XX} failed due to the following error: 80004005 Unspecified error

I am working on VB.NET WinForm Application ( 32 bit) which references third party COM dll (32 bit). My Target Platform points to x86. I registered the dll using command prompt as administrator. However while creating the instance of dll it intermittently not able to create it and I get the following COM exception:
Retrieving the COM class factory for component with CLSID
{0CBDC6C1-3D1E-4CEB-A89E-5D081985E874} failed due to the following
error: 80004005 Unspecified error (Exception from HRESULT: 0x80004005
(E_FAIL)).
Can anyone help me with this, please?

System.Runtime.InteropServices.COMException | vb.net

I know this question has been answered many times but I have tried all previous suggested resolution.
1.) The target CPU is x86
2.) I have registered the ocx and dll files
The application is working fine on old machines (all OS) but not on new images.
Here is the log :
Framework Version: v4.0.30319 Description: The process was terminated
due to an unhandled exception. Exception Info:
System.Runtime.InteropServices.COMException at
System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(System.Guid
ByRef, System.Object, Int32, System.Guid ByRef) at
System.Windows.Forms.AxHost.CreateWithLicense(System.String,
System.Guid) at
System.Windows.Forms.AxHost.CreateInstanceCore(System.Guid) at
System.Windows.Forms.AxHost.CreateInstance() at
System.Windows.Forms.AxHost.GetOcxCreate() at
System.Windows.Forms.AxHost.TransitionUpTo(Int32) at
System.Windows.Forms.AxHost.CreateHandle() at
System.Windows.Forms.Control.CreateControl(Boolean) at
System.Windows.Forms.Control.CreateControl(Boolean) at
System.Windows.Forms.AxHost.EndInit() at
Restaurant.frmMain.InitializeComponent() at
Restaurant.frmMain..ctor()
Exception Info: System.InvalidOperationException at
Restaurant.My.MyProject+MyForms.Create__Instance__[System.__Canon,
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089] at
Restaurant.frmMain.Main()
Here is how I am registering the files :
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Caspol -q -machine -addgroup 1 -url file://C:/xyz/* FullTrust -name "V Drive"
regsvr32 c:\xyz\crystl32.ocx
regsvr32 c:\xyz\MSCOMCT2.OCX
regsvr32 c:\xyz\MSDATGRD.OCX
regsvr32 c:\xyz\cpeaut32.dll
regsvr32 c:\xyz\msstdfmt.dll
Crystal reports runtime engine for .NET 4 framework in installed on the system (both x86 and x64).
I had this issue once.
I ran Visual Studio as administrator.
Also make sure you know which setting your platform is for the build: AnyCPU, x86, x64
For you its x86 so try using AnyCPU!
Try debugging the issue
I read an article from Microsoft which said you can debug where this exception is occurring by:
Debug > Exceptions... and use the Find option to locate System.Runtime.InteropServices.COMException. Tick the option to break when it's thrown and then debug your application.

Unity Di container not working with 64 bit build

I am using Unity for in WCF service to load component.
I am referring below mention article.
https://msdn.microsoft.com/en-us/library/vstudio/hh323725(v=vs.100).aspx
Service is working fine when i build service in visual studio with build option option any CPU.
As one third party component required 64 bit specific build. So i selected 64 bit build option.
I have downloaded Unity code and build for 64 bit but it is also not working.
I am getting below mention exception.
Could not load file or assembly 'Common.Unity' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'Common.Unity' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Common.Unity' could not be loaded.
As this is not issue of Unity.
It is issue of IISExprees of VS2012 which is support on 32 bit.
Can't get IIS Express 8 beta to run website as 64-bit process
https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3254745-allow-for-iis-express-64-bit-to-run-from-visual-st

Getting errors in registering the COM DLL

when i was trying to register my own com dll it is giving me error as
"The module ClassLibrary was loaded but entry point dllregister server was not found.

dll not loading- FileLoadException

The problem I am having is that I am getting a System.IO.FileLoadException when trying to load the RWLock.dll on a test box and Windows xp machines.
This is the exception that is thrown when it tries to load the dll on the windows 2003 server machine (most likely 32 bit):
System.IO.FileLoadException: A procedure imported by 'rwlock, Version=1.0.3889.27926, Culture=neutral, PublicKeyToken=null' could not be loaded.
File name: 'rwlock, Version=1.0.3889.27926, Culture=neutral, PublicKeyToken=null' ---> System.Runtime.InteropServices.COMException (0x8007007F): The specified procedure could not be found. (Exception from HRESULT: 0x8007007F)...
However, we have not had any problems trying to run this on a Windows 2007* server machine (64 bit).
Any ideas? Thanks in advance :)
*windows 2008(oops)
The error message is telling you that RWLock.dll tries to import a function that doesn't exist from another DLL. This probably means that RWLock is trying to import an API function that exists on the (I presume you meant instead of "Windows 2007 Server") Windows 2008 Server machine, but not on Windows 2003 or earlier.
You can use Dependency Walker to figure out what it's trying to load and where it's trying to find that missing function, but it won't help make it available on the Windows versions where it doesn't exist.
The other possibility is that RWLock has a dependency on another DLL that it provides, but you're not re-distributing it properly. Dependency Walker can help with this, too.