none
Error In Registering Dll File in windows 7?

    Question

  • Hi All,

    I have created a Dll file using a class library,but when i tried to register that dll it is throwing following error

    And My Code is as follows

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.InteropServices;
    namespace ActiveXSampleApp
    {
                [ProgId("ActiveXSampleApp.Class1")]
            [ClassInterface(ClassInterfaceType.AutoDual)]
            [Guid("FF9743C7-86AD-456E-B107-D76E8CFFEE0F")]
            [ComVisible(true)]
        public class Class1
        {
                    [ComVisible(true)]
                    public string Something()
                    {
                        return "Hi Am from Library File";
                    }
    
        }
    }
    

    Any Suggestion Would be of great help

    Thanks


    Arjun

    Friday, April 26, 2013 6:00 AM

Answers

All replies

  • Type "regsvr32 name.dll" into the Command Prompt and press "Enter." Note that "name.dll" should be replaced with the name of the DLL that you want to register. For example, if you want to register the iexplore.dll, type "regsvr32 iexplore.dll."

    Well, you don't specify if it's a 32 or 64 bit dll and you don't include the error message, but I'll guess that it's the same issue as described in this KB article: Error Message When You Run Regsvr32.exe on 64-Bit Windows

    Quote from that article:

    This behavior occurs because the Regsvr32.exe file in the System32 folder is a 64-bit version. When you run Regsvr32 to register a DLL, you are using the 64-bit version by default.

    Solution from that article:

    To resolve this issue, run Regsvr32.exe from the %SystemRoot%\Syswow64 folder. For example, type the following commands to register the DLL:
    cd \windows\syswow64
    regsvr32 c:\filename.dll

    If the DLL is 32 bit:

    Copy the DLL to C:\Windows\SysWoW64\
    In elevated cmd: %windir%\SysWoW64\regsvr32.exe %windir%\SysWoW64\namedll.dll

    if the DLL is 64 bit:

    Copy the DLL to C:\Windows\System32\
    In elevated cmd: %windir%\System32\regsvr32.exe %windir%\System32\namedll.dll

    I know it seems the wrong way round, but that's the way it works. See:

    http://support.microsoft.com/kb/249873
    Quote: "Note On a 64-bit version of a Windows operating system, there are two versions of the Regsv32.exe file:
    The 64-bit version is %systemroot%\System32\regsvr32.exe.
    The 32-bit version is %systemroot%\SysWoW64\regsvr32.exe.

    Friday, April 26, 2013 8:47 AM
  • Hi,

    Thanks for the Reply, I tried the way you suggested.

    But it is not working out.

    Thanks


    Arjun

    Friday, April 26, 2013 9:16 AM
  • Hi,

    Please see the doc at http://msdn.microsoft.com/en-us/library/h627s4zy(v=vs.100).aspx

    It seems you assumed that it is enough to make this a COM DLL. It still creates a .NET DLL that the regasm tool allows to expose to COM. regsvr32 is for "true" COM DLLs.


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".


    Friday, April 26, 2013 11:17 PM
  • Building COM Objects in C#

    http://www.codeproject.com/Articles/7859/Building-COM-Objects-in-C


    Faisal Ahmed Farooqui

    Saturday, April 27, 2013 8:19 PM
  • Example COM Class (C# Programming Guide)

    http://msdn.microsoft.com/en-us/library/c3fd4a20.aspx


    Faisal Ahmed Farooqui

    Saturday, April 27, 2013 8:19 PM