HELP:: Specified cast is not valid

trying to call Find() from a test dll im messing with and I keep getting the error"Specified cast is not valid."

here's a little snippet of what im working with.....

foo.h

__declspec(dllexport) UINT Find();


foo.cpp
1
2
3
4
UINT Find()
{
	return 1;
}


C#
test.exe -> interface
1
2
3
4
5
6
7
8
9
10
11
[ComImport, CoClass(typeof(object)), TypeIdentifier, CompilerGenerated, Guid("myguid")]
    public interface CSmart : ISmart
    {
    }

    [ComImport, TypeIdentifier, CompilerGenerated, Guid("myguid")]
    public interface ISmart
    {
        [DispId(1)]
        uint Find();
}



1
2
3
4
5
6
7
8
9
10
11
12
 private CSmart caller;

 //NEW METHOD
            this.caller = (CSmart)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("myguid")));
            try
            {
                caller.Find(); <-- when i get here is when the error pops
            }catch (Exception ex)
            {
                //Specified cast is not valid.
            }


in dependancy walker its showing

1(0x0001) | 0(0x0000) | unsigned int Find(void) | 0x00011091
Last edited on
You're aware that you're on a site whose name is "cplusplus.com" in a C++ programming forum, yes?
im aware the little piece of code provided from the dll is in c++ not to mention most people know more then one language of code, yes?
Last edited on
Topic archived. No new replies allowed.