Implementing an IDispatch Interfac in C# DLL

R

Roland Schoen

Hello Discussion Group,

i need your help a little bit for a better understanding in implementing an
IDdispatch iterface in a C# written dll.

The type lib i have i call from a PHP script. This works fine the whole
time. But since there were installed some windows updates my page doesn't
work anymore.

I get the following error message:

Warning: Unable to obtain IDispatch interface for CLSID
{E07F90DF-9E30-4F11-8059-85049B977CC6}: No description available in [Path to
script]\dllcall.php on line 10

Fatal error: Call to a member function on a non-object in [Path to
script]\dllcall.php on line 11

This is the PHP script for the COM call:
----------------------------------------------
$parameter[0] = 12345;
$parameter[1] = "My String";
$parameter[2] = false;
$obj = new COM ("TestLib.MyClass");
$value = $obj -> tf($parameter);
print($value);
----------------------------------------------


And this is my c# code for the type lib:
----------------------------------------------
using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyKeyFileAttribute("testlib.snk")]
[assembly: AssemblyVersionAttribute("1.0.0.0")]
[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")]
[assembly: AssemblyConfigurationAttribute("beta")]
[assembly: AssemblyCultureAttribute("")]
[assembly: AssemblyDescriptionAttribute("test")]
[assembly: AssemblyCopyrightAttribute("test")]
[assembly: AssemblyCompanyAttribute("test")]
[assembly: AssemblyProductAttribute("test")]
[assembly: AssemblyTitleAttribute("by Roland Schoen")]
[assembly: CLSCompliant(true)]
[assembly: ComVisible(true)]

namespace TestLib
{
[ComVisible(true)]
[Guid("E07F90DF-9E30-4f11-8059-85049B977CC6")]
public class MyClass
{
public static string MyFunc (params object[] parameters)
{
if (parameters[0].GetType().ToString() == "System.Int32")
return "Parameter 0 is an Integer";
return "Parameter 0 is no Integer";
}

public string tf (params object[] parameters)
{
if (parameters[0].GetType().ToString() == "System.Int32")
return "Parameter 0 is an Integer";
return "Parameter 0 is no Integer";
}

public string TestFunc()
{
string data = "I'll be Back";
return (data);
}
}
}
----------------------------------------------

Maybe someone could show me how to implement an IDispatch interface, or give
me an hint how i could do this, because it's a littel bit confusing to me.


regards from Germany
Roland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top