PDA

View Full Version : SUITE: Cannot find entry point to managed code custom action



DLee65
10-28-2015, 06:39 AM
I have a C# managed code custom action that I developed, that when tested independently from InstallShield, works correctly.
But when I try to integrate this into InstallShield I get an error message indicating that it could not find the entry point.

I have been over the steps for this: http://helpnet.flexerasoftware.com/installshield21helplib/helplibrary/SteActionManagedCd.htm
Below is a quick diagram of what I have in my C# code.


using ...

namespace MyCustomAction
{
[Guid[Guid("BAFAEAED-08C6-4679-B94E-487A4D89DE63")]
[TypeLibType(4288)]
public interface ISuiteExtension { ... }

public class DoMyAction
{
const UInt32 ERROR_INSTALL_FAILURE = 1603;
const UInt32 ERROR_SUCCESS = 0;
object _pDispatch = null;
ISuiteExtension _suiteExtension;

ISuiteExtension GetExtensionFromDispatch(object pDispatch)
{
if (Marshal.IsComObject(pDispatch) == false)
throw new System.ContextMarshalException("Invalid dispatch object passed to CLR method");
return (ISuiteExtension)pDispatch;
}

public UInet32 DoMyActionMethod(object pDispatch)
{
_pDispatch = pDispatch;
DoSomething();
return ERROR_SUCCESS;
}

private void DoSomething() { ... }

}

}

In my Suite project I added the .dll file to the events.
I set the class to 'DoMyAction'
I set the method to 'DoMyActionMethod'
Finally I schedule the custom action to run. It tries to run but I get:
10-28-2015[07:08:04 AM]: (CLR Action): Could not interpret instance of DoMyAction

What is it that I am missing? Do I need to add a def file like I do with C++ custom actions so the name is not decorated?
What I suspect is that I need to have an explicit constructor as the entry point but if I do that I cannot have a return value, and the example shown on the site referenced above does not have an explicit constructor either.

Thanks.

DLee65
10-28-2015, 06:46 AM
I just found a link to the same issue:
https://community.flexerasoftware.com/showthread.php?217688-(CLR-Action)-Could-not-interpret-instance-of-in-managed-code-custom-action

Just one recommendation for whoever is doing documentation, if you can make the class declaration requirement a bit clearer, perhaps bold text, in the help page that would be appreciated. I read though this document several times and totally missed the following:

The following sample C# code corresponds with a Class setting value of TestCLRAction.TestCLRClass and a Method setting value of TestCLRMethod: