Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 .NET4 VC++
Hi,
 
I am trying to access COM Dll in .net framework using c#, But not able to initilaize the object of COM classes.all required dll are built succesfully in VC++ But while accessing in C#, it throws error as below:
 
"Retrieving the COM class factory for component with CLSID {4F3843A4-048B-11D4-93D8-0050BAD440B8} failed due to the following error: 800401f0."
 
I am not able to get any help from Google even. Kindly assist.
 
Thanks and Regards
Kush Sharma
Posted 7-Feb-13 1:46am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hello,
 
Your error code (800401f0) seems to indicate a CoInitialize or a CoCreateInstance error, this could be linked to your COM DLL not being properly registered.
 
You should try to run "rgsvc" with option "-r" on your DLL and then run your C# app.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Thanks Fred. Regsvr32 or grsvc please confirm and give me some examples how to register. I will really appreciate your help on this.
  Permalink  
Comments
Fred Flams at 7-Feb-13 8:50am
   
I'd say regsvr32, and the command line would be (from memory) "regsvr32 -r ", if incorrect, "regsvr32 -?" should help you.
Fred Flams at 7-Feb-13 8:52am
   
Actually I should have type regsvr32 -? myself, the option is -i
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Thanks Fred.
 
I have tried But it thorws error as dll was loaded but the entry point DllInstall was not found.
 
make sure it si valid dll or OCX file, I have build this COM dll and built in VC++ PROJECT WITH OUT ANY ERROR.
 
Please help on it now.
  Permalink  
Comments
Fred Flams at 7-Feb-13 9:14am
   
By the way try answering to my post with the "comment" button rather than posting a new solution, that way I get notified that someone is reacting to my post.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

In that case your problem is stemming from there.
I your DLL doesn't have a DLLInstall entry point (and that is not mandatory to have) then you won't be able to reference directly from your C# application.
You'll have to use the P/Invoke mecanism to interact with your COM DLL from the C# application:
 
[System.Runtime.InteropServices.DllImport("yourComLib.dll")]
static extern void SomeMethod(....);
 
You will need to define a external static method in you C# application for each COM method you want to use. But if you want to be able to reference your COM DLL then you should make sure it has DLLInstall and DLLUninstall method.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

thanks Fred,
 
But can you explain with some examples as i am not able to process it further on this.
 
below is my DLL
 
[System.Runtime.InteropServices.DllImport("ExactaUtil.dll")]
 
currently i am usingl ike this way:
 
protected EXACTAUTILLib.IUtilObj m_objUtil;
 
// Create an instance of the Util class.
m_objUtil = new EXACTAUTILLib.UtilObjClass();
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

thanks Fred,
 
But can you explain with some examples as i am not able to process it further on this.
 
below is the procsedure currently i am using to call my DLL:
 
protected EXACTAUTILLib.IUtilObj m_objUtil;
// Create an instance of the Util class.
m_objUtil = new EXACTAUTILLib.UtilObjClass();
m_objUtil.SetDBConnectionInfo(m_szDBUserID, m_szDBPassword, m_szAdoDSN, m_szOdbcDSN);
 
please explain how i can call using P/Invoke mecanism
 

 
thanks and Regards
Kush Sharma
  Permalink  
Comments
Fred Flams at 7-Feb-13 10:37am
   
Well actually in your case, the easiest would be to make sure that the COM DLL has the DllInstall and DllUninstall entry points as it will be relativelly complex to convert your code into P/Invoke.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 349
1 Nirav Prabtani 268
2 Richard Deeming 215
3 CHill60 170
4 _Amy 145
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,067
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100