Access COM DLL using VS 2008 on Windows 7 64 bit - c#

I am using Windows 7 64 bit OS and VS 2008 SP1 as development environment.
One of the console application uses a COM component. When I try to create an instance of a class from the COM component, I got following error:
Creating an instance of the COM component with CLSID {CE92C3B9-9A93-40E1-85AB-6A49170AEF7F} from the IClassFactory failed due to the following error: 80010105.

I assume that you're building an managed .NET application from the fact that you added a C# tag to the question.
Managed applications are started in the as a 64-bit process unless you explicitly define it to be launched as a 32 bit application through ProjectProperties - Build - Platform Target.
If the COM component you're loading (in-process?) comes from a 32-bit native DLL then the instantiation will fail since you obviously cannot mix CPU models in 1 process.

Related

COM function fails on VBscript but not VB6 on Win64

I have written a COM control in c# .Net 4.5, this COM control uses a 3rd party dll to communicate with a USB device.
On Windows 7 32bit everything works 100% from both VBScript and the VB6 app. On Windows 7 64bit the VBScript fails when calling the 3rd party dll function that uses the USB device.
The exception is: "System.AccessViolationException" with message: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
What I don't understand is that the same COM control (and the same USB driver) works when instantiated from the VB6 app, but not from the VBScript.
I have looked at the loaded assemblies and registry access using Process Monitor when running the VB6 app and the VBScript but I cannot see anything out of the ordinary.
Any suggestions of what I can troubleshoot or test next?
Here's the deal. Applications written from VB6 are 32-bit. Your application works on 32-bit Windows and from a VB6 app on Windows 64 (which is running as 32-bit, since VB6 produces 32-bits. So, we know that your DLL works with 32-bit applications.
The thing is, when you run a VB script on Windows 64, it runs as a 64-bit process and you have a mismatch with your 32-bit DLL. If you run the VB script with the 32-bit version of the VB script engine (c:\windows\syswow64\wscript.exe or c:\windows\syswow64\cscript.exe) does it work? It probably will.
Now, if you compiled your DLL with the AnyCPU processor setting, then you can still register your DLL and get it to work with a 64-bit process. Just be sure to use the regasm.exe that is in the 64-bit hive.
For example register your DLL as such,
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /tlb /codebase c:\path\to\yourdll.dll

Windows 7 64 bit dll registering vs Windows 8.1 64 bit dll registering

I have a 32bit compiled dll that contains vb6 code. On my previous os, which was windows 7 64bit, i was able to register and run this dll fine within my c# application. Now, running windows 8.1, when i try to register the same dll, it registers fine, however when i try to read the dll in my code, i get:
Retrieving the COM class factory for component with CLSID
{D19A00C4-A7F9-4E14-A5E1-D060B7EB57F3} failed due to the following
error: 80040154 Class not registered (Exception from HRESULT:
0x80040154 (REGDB_E_CLASSNOTREG)).
The 32bit dll (compiled as Interop.VB6Class) is used in a c# class
that is build against x86.
I have tried both regasm from my 64bit folder and the 32bit folder, no luck
When i run Dependency Walker (a nice little application that checks if all your dll's dependencies are available and that your cpu version for the dll and its dependencies match), I still get the message "Modules with different CPU were found".
I have followed numerous links and advice, so if anyone can help me, I would accept you as my savior and forever call you king.
Just a suggestion, but are you 100% sure that your project settings are correct. Your Platform Target should be x86 and the Prefer 32-bit check box should be ticked. Also are you running the Debug version or the release version?. You need to set your 32 bit settings for both environments. For the command line version print out the following to ensure your environment is correct.
Console.WriteLine("OS {0}, Process {1}", System.Environment.Is64BitOperatingSystem, System.Environment.Is64BitProcess);
I know it's a long shot but it might help in finding the root cause of the problem.

Error using the Library on a Windows Server 2008 SP2 64-bit

I developed an application (C# Framework 4) using the fdf toolkit running on a 32 bit server and everything works well.
I have migrated this application to a Windows Server 2008 SP2 64 Bits and sometimes this application gives me this error:
System.Runtime.InteropServices.COMException (0x800703FA): Retrieving
the COM class factory for component with CLSID
{CB830891-2E18-11D1-B8CF-00A0C9259304} failed due to the following
error: 800703fa Illegal operation attempted on a registry key that has
been marked for deletion.
After this error, I recycle the website pool and the application runs well again.
Details of the application:
Registered the libraries FDF.dll, FDFACX.dll and FDFTK.dll in c:\windows\SysWOW64.
Enabled in the web site pool the property 'Enable 32-Bit Applications'
Enabled 'Do not forcefully unload the user registry at user logoff ' property in the Group Policy Editor
Could you help me?
Thanks¡¡¡
What is the target platform you are building your application for? It will be either x86, x64, Itanium, or most likely "Any CPU".
You can try setting it to x86, that way you know everything is built to use the 32-bit version of .Net. Alternatively you can run CorFlags on your assembly(ies) to change it to x86 without recompiling.
If that doesn't solve the problem then we will need more code :)

Excel Interop error

I'm having a problem with running an application I made on another computer. This is the error message I'm getting:
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154
I searched it on Google, and found out that it means that I need to register that specific component in regedit, but I don't know how to do it, or where to find that component, so please help me.
I used C# in VS 2010 to make my application. One more thing, I don't know if it matters - I installed this application on 3 different computers, and this is the only one that gives me that error - it is a HP all-in-One computer.
for component with CLSID {00024500-0000-0000-C000-000000000046}
That's the guid for Microsoft Excel's Application class. Two very basic reasons you'll get this error:
Microsoft Office is not installed on that machine
The machine has a 64-bit operating system and you installed the 32-bit version of Office. You have to force your program to run in 32-bit mode. Project + Properties, Build tab, change the Platform target setting to x86
The machine has a 64-bit operating system and you installed the 64-bit version of Office 2010. Same fix as above but now you have to make sure to select the AnyCPU target.

Deploying a C# app that uses Microsoft.Ink.dll

I have a legacy app that captures signatures. It uses Microsoft.Ink.dll that came from a Windows Tablet SDK. I am maintaining the app on Windows 7 VS 2010 and it runs fine on my box. When I deploy the app to Windows Server 2003 the app fails with the following error:
Exception during StringFormat: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. Datapump error on interface Risk Assessment Signatures: Retrieving the COM class factory for component with CLSID {937C1A34-151D-4610-9CA6-A8CC9BDB5D83} failed due to the following error: 80040154.
Regsvr32 on the dll fails.
I assume that this is because related dll's are missing.
Is there any way to delete the old ink dll and use a more modern dll that I can properly deploy? If not what is the best way to deploy this app?

Categories

Resources