Feb 10, 2016 at 7:11pm UTC
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 Feb 10, 2016 at 8:21pm UTC
Feb 10, 2016 at 8:57pm UTC
You're aware that you're on a site whose name is "cplusplus.com" in a C++ programming forum, yes?
Feb 10, 2016 at 10:16pm UTC
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 Feb 10, 2016 at 10:18pm UTC