none
method of a com dll returns REGDB_E_CLASSNOTREG instead of "S_OK" RRS feed

  • Question

  • Hello

    I created a dll in C# with visual studio 2010 ( I use the version 2.0 of .Net framework).

    I am supposed to call this dll on 2 separates C++ project. So, In order to communicate managed code to unmanaged code, I use COM object.

    The first C++ project exists in the development machine (OS Windows 7) and is created with the visual studio 2005. In this case, I import the dll, and it works correctly.

    The second C++ project exists in a virtual machine (OS Windows xp) and is created with visual studio 2003. In this case, I import the dll, no compilation errors, but when running, I call the “CreateInstance” method in order to create an HRESULT object, this method do not returns a “S_OK” value, but it returns a "REGDB_E_CLASSNOTREG" value.

    Looking on the internet, a lot of people recommend the registration of the dll file by typing at visual studio command prompt the following command:

    "regsvr32 CheminFichierDll\NomDll.dll" 

    But, running this command, Windows show the following message error:

    " c:\dkmetre\mdlApps\v63\dllExcel\lectureFichierExcel.dll" Was loaded but the entry point DllRegisterServer was not found. This file can not be saved."

    I do not know the problem is on what level, need your help.

    Thank you in advance                                               


    • Edited by zineba Thursday, June 26, 2014 10:51 AM
    Thursday, June 26, 2014 10:50 AM

Answers

  • Hello zineba,

    1. In this case, the target .NET framework version becomes important.

    2. Try to ensure that the correct target .NET framework is specified in the Project|Application|Target Framework setting.

    3. Also, use the correct version of regasm.exe. Refer to :

    http://www.geeksengine.com/article/register-dll.html

    - Bio.


    Please visit my blog : http://limbioliong.wordpress.com/

    • Marked as answer by zineba Thursday, June 26, 2014 5:45 PM
    Thursday, June 26, 2014 4:56 PM

All replies

  • Hello zineba,

    1. I assume that lectureFichierExcel.dll is a class library written in C#.

    2. In order to register this class library DLL, you need to call RegAsm.exe, e.g. :

    regasm lectureFichierExcel.dll

    3. The reason why things worked in your development machine is possibly due to the "Register for COM interop" check box being checked in the Project|Build setting.

    - Bio.


    Please visit my blog : http://limbioliong.wordpress.com/

    Thursday, June 26, 2014 11:30 AM
  • Hello Bio

    thank you for your reply

    so,

    1. yes lectureFichierExcel.dll is a class written in C#

    2. when i run regasm command, I get the follow message error: Regasm error: Failed to load lectureFichierExcel.dll because it is not a valid .Net assembly.

    3. I verify in the class library project setting, the command "Register for COM interop" is not checked


    Thursday, June 26, 2014 2:17 PM
  • I checked the .nET framework version in VS2003, it is 1.1 and the dll is created with the framework .net 2.0.

    Can this version difference cause any problem ?

    Thursday, June 26, 2014 2:56 PM
  • Hello zineba,

    1. It is possible that lectureFichierExcel.dll was compiled as a 64-bit DLL and the virtual machine is Windows XP 32-bits.

    2. Go to Project Properties|Build section. For the "Platform target" section, select "x86".

    3. Make sure that "Any CPU" is not the one selected as this will target the platform of the machine in which the program is compiled.

    4. After re-compilation, copy the output lectureFichierExcel.dll to the Windows XP virtual machine and try regasm.exe again.

    - Bio.


    Please visit my blog : http://limbioliong.wordpress.com/

    Thursday, June 26, 2014 3:32 PM
  • Hello Bio,

    I tried your suggestion but I have always the same message error

    Thursday, June 26, 2014 4:07 PM
  • Hello zineba,

    1. Is your Windows 7 machine 64-bits ?

    2. Is your Windows XP virtual machine 32-bits ?

    - Bio.


    Please visit my blog : http://limbioliong.wordpress.com/

    Thursday, June 26, 2014 4:17 PM
  • hello

    Both machines are 32-bits

    Thursday, June 26, 2014 4:41 PM
  • Hello zineba,

    1. In this case, the target .NET framework version becomes important.

    2. Try to ensure that the correct target .NET framework is specified in the Project|Application|Target Framework setting.

    3. Also, use the correct version of regasm.exe. Refer to :

    http://www.geeksengine.com/article/register-dll.html

    - Bio.


    Please visit my blog : http://limbioliong.wordpress.com/

    • Marked as answer by zineba Thursday, June 26, 2014 5:45 PM
    Thursday, June 26, 2014 4:56 PM
  • yeees it works now

    thank you very very very much for your help bio :).

    I visited the url above and I used the suitable version of regasm.exe and it works.


    Thursday, June 26, 2014 5:45 PM