views:

50

answers:

0

I'm working on an internal project based on the Registration Free Com-Server in Microsoft's All-In-One Microsoft's All-In-One Framework. The sample shows how to generate a registration free c# COM server for a c++/native code application. As a newbie at doing COM-Interop, using this demo seemed like a good idea. This sample shows how to do this without have to register the COM object on the target machine, it simplifies deployment issues.

I've copied the demo code as exactly as possible and am getting the following error when I call any of my classes in the com object -

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.
This is usually a result of calling a function declared with one calling convention with a 
function pointer declared with a different calling convention.

I've keep the demo code in the program and if I skip over my new classes and call the demo objects, everything works just fine. In a simplifed version, my c# com object is -

[Guid("ba8de293-b3cb-4c0b-b58f-25fdbb434e11")] // IID
[ComVisible(true)]
public interface IFields
{
    int TestFileNameProperty { get; set; }
}
///     
[Guid("BD7D1C3F-B70D-4821-A285-EAFDDB16689C")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[ComVisible(true)]
public interface IFieldsEvents
{
    [DispId(100)]
    void TestFileNamePropertyChanging(int newValue, ref bool Cancel);
}
///     
[ClassInterface(ClassInterfaceType.None)] // No ClassInterface
[ComSourceInterfaces(typeof(IFieldsEvents))]
[Guid("D117BD17-7742-4e47-A126-BA1E7110EECD")] // CLSID
//[ProgId("CSRegFreeCOMServer.Fields")]  // ProgID
[ComVisible(true)]
public class Fields : IFields
{

    public Fields()
    {
        TestFileNameProperty = 123;
    }
    public int TestFileNameProperty { get; set; }
}

I've put the same attributes on in the same order as the demo code (except for new GUID's). I have my Fields Class and the demo code in the same file, so it is all complied the same. So my problem is not related to compiler settings. Also, there is a required Manifest file and that has been updated.

When I look at the .tlh & .tli files that are generated for the c++ code to call, everything looks identical.

Suggestions where to look?