Registration COM c# component - TYPE_E_REGISTRYACCESS

2

I have problem with registration my COM C# component ,here is the code:

[Guid("BBA10049-5A29-46f2-9D6A-084A38345F11"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface DBCOM_Events
{
}

[Guid("793DD198-0E9C-4b2d-9C4D-609584D8B4DC"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(DBCOM_Events))]
public class CSharpIstreamWraper : IStream
{

        public Stream InnerStream;
        public string name;


        public CSharpIstreamWraper(Stream NetworkStream, string name_ = null)
        {
            InnerStream = NetworkStream;
            name = name_;

        }

        public void Clone(out IStream istream)
        {
            istream = (CSharpIstreamWraper)(new CSharpIstreamWraper(InnerStream));
        }

        public void Commit(int i1)
        {
            throw new NotImplementedException();
        }


        public void CopyTo(IStream istr, long i1, IntPtr ptr1, IntPtr ptr2)
        {
            throw new NotImplementedException();
        }

        public void LockRegion(long l1, long l2, int i1)
        {
            throw new NotImplementedException();
        }

        public void Read(byte[] pv, int cb, System.IntPtr pcbRead)
        {
            Marshal.WriteInt64(pcbRead, (Int64)InnerStream.Read(pv, 0, cb));
        }

        public void Revert()
        {
            throw new NotImplementedException();
        }

        public void Seek(long dlibMove, int dwOrigin, System.IntPtr plibNewPosition)
        {
            Marshal.WriteInt64(plibNewPosition, InnerStream.Seek(dlibMove, (SeekOrigin) dwOrigin));
        }


        public void SetSize(long l1)
        {
            throw new NotImplementedException();
        }

        public void Stat(out  System.Runtime.InteropServices.ComTypes.STATSTG st, int i)
        {
            st = new  System.Runtime.InteropServices.ComTypes.STATSTG();
        }

        public void UnlockRegion(long l1, long l2, int i1)
        {
            throw new NotImplementedException();
        }

        public void Write(byte[] pv, int cb, System.IntPtr pcbRead)
        {
            int written = Marshal.ReadInt32(pcbRead);
            InnerStream.Write(pv, 0, written);

        //    InnerStream.Write(pv, 0, cb);
        //    Marshal.WriteInt64(pcbRead, cb);
        }

}

I used the guidgen.exe utility and select the Registry Format for generating Guid and create a strong name, use the utility SN.EXE. After these steps When i try to register it using regasm:[regasm xxx.dll/tlb:xxx.tlb]

i get error: RA0000 HRESULT 0x8002801c

what i do wrong?

c#
com
registry
asked on Stack Overflow Oct 12, 2012 by Jerry Filthner • edited Oct 13, 2012 by Roman R.

1 Answer

2

On Windows Vista and up, you must run Regasm.exe from an elevated command prompt so that the tool has the permission to write to the registry. Click the Start button, Programs, Accessories. Right-click the "Command Prompt" shortcut and select "Run as administrator".

If you still have trouble then you can use SysInternals' ProcMon utility to see Regasm.exe writing to the registry. It is the TypeLib key that it has trouble writing to, you'll see it fail in the ProcMon trace with a possibly better diagnostic.

Note that you ought to use the /codebase option for Regasm.exe on your dev machine so that you don't have to put the assembly in the GAC. You can ignore the warning that generates.

answered on Stack Overflow Oct 13, 2012 by Hans Passant

User contributions licensed under CC BY-SA 3.0