Alaa Jabre
Alaa Jabre

Reputation: 1893

using .net dll as com in php failed

I have a .net dll that I want to use in my php application
I have tested the dll on .net app and it worked perfectly

my c# class:

namespace CryptoCs
{
    [Guid("15D16831-D6BE-43C4-AB4F-F0BAA35987DB")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("CryptoCs")]
    [ComVisible(true)]
    public class Crypto : iCryptoCs
    {
        public Crypto()
        {
        }

        public bool Login(string username, string password)
        {
            // some code
        }                                    
    }

    [Guid("5BDBB53A-571A-4EC7-B37E-A4D2A6A54DEB")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [ComVisible(true)]
    public interface iCryptoCs
    {
        [DispId(1)]
        bool Login(string username, string password);        
    }
}

my usage code is:

$crypto = new COM('CryptoCs.Crypto');

this page give this error:

Failed to create COM object

I tried to register the dll using gacutil.exe the result was:

Assembly successfully added to the cache

but the error wasn't fixed

I tried regasm.exe and the result is:

Types registered successfully

still the error is the same

I tried REGSVR32.exe but it gabe me this error:

Can't find entry point

I'm on windows server 2003 sp2 using vs2010 .net4

Upvotes: 0

Views: 481

Answers (1)

Simon Mourier
Simon Mourier

Reputation: 138950

The standard registration tool for .NET assemblies is indeed regasm.exe, with /Codebase if you don't put it in the GAC (but you put it in the GAC apparently).

The progid you use in php should be the same as what you specified in .NET, so "CryptoCs", instead of "CryptoCs.Crypto" here

Also, I suggest you remove all the ClassInterface and InterfaceType attributes, as it's better to use the defaults in general.

Upvotes: 1

Related Questions