|
while compiling My ComClient Iam getting this error .
error C2259: 'CComObject<class CComClient>' : cannot instantiate abstract class due to following members:
warning C4259: 'long __stdcall IDSNInfo::SetEngineInfo3(unsigned short *)' : pure virtual function was not defined.
what might be the error. Iam compiling in Unicode Relese Minsize.
|
|
|
|
|
Hello Krishnatv,
Check out the parameter to SetEngineInfo3(), i.e. type unsigned short*.
See whether this parameter corresponds with the parameter type declared in the IDL file.
- Bio.
|
|
|
|
|
HI Lim Bio Liong
Thanks for your great suggestion.you are right my SetEngineInfo3() parameters are different in .h file and IDL file.
Now I solved, Thanks once again.
Bye,
Krishna.
|
|
|
|
|
Hello Krishnatv,
Congratulations and best wishes to your project.
- Bio.
|
|
|
|
|
I need to pass user defined COM class through COM interface. I passed its interface as I can not pass its coclass. Please correct me if I am wrong.
The code was compiling. Now the problem is I have some data types in the coclass and can not use them from interface.
Could you please let me know how to solve this.
Here below is the code:
STDMETHODIMP CTP_Interface_Wrp::GetObligorInputData(ITP_CompInputData_Wrp *pVal)<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState())<br />
<br />
<br />
pTP_DLL_Interface->GetObligorInputData(pVal->pTP_CompanyInputData);
return S_OK;<br />
}<br />
Actually pTP_CompanyInputData is member vairable of TP_CompInputData coclass. This can not be accessed from its interface class ITP_CompInputData.
modified on Tuesday, January 08, 2008 10:43:01 PM
|
|
|
|
|
I fixed the problem by type casting interface with its coclass.
((CTP_CompInputData_Wrp*)pVal)->pTP_CompanyInputData
Please let me know if this is the right approach.
|
|
|
|
|
Interfaces will understand the data types, those are standard, or defined in .idl.
Search for UDT in COM, you will get lot of articles, telling how to achieve it.
|
|
|
|
|
I have created a class library in C# .Net 2005. I'm not able to create an instance of C# interface class in VC++/or COM dll. It gives an error
0x80040154 "Class not registered"
I also tried registering using regasm. It gives the message Types registered success
I'm not sure if i'm doing it right. Your help will be appreciated. I have attached the code snippet
C#
AssemplyInfo.cs
[assembly: ComVisible(true)]
[assembly: Guid("A4B0A925-5F27-42f3-B8D0-028248A7C210")]
ProcessClass.cs
amespace analyst1
[Guid(ProcName.InterfaceId)]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface INewInFace
{
[DispId(1)] void BatchStart();
}
[Guid(ProcName.ClassId)]
[ClassInterface(ClassInterfaceType.None)]
public class ProcName : INewInFace
{
internal const string ClassId = "0129FAAF-456E-4e4b-9A72-9685841EAB66";
internal const string InterfaceId = "A2F72F34-0340-49f5-8FDF-7A23A74CC370";
internal const string EventsId = "46C617A1-C148-4c9a-B064-285892110FC4";
public void BatchStart() { }
}
VC++ code
#import "..\\analyst1.tlb" no_namespace named_guids
the follwoing line gives error message "Class Not registered"
INewInFacePtr cp (__uuidof(INewInFace));
|
|
|
|
|
Member 4219419 wrote: INewInFacePtr cp (__uuidof(ProcName));
The interface INewInFace is not a class therefore it's not surprising that you get Class Not Registered.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Hi All,
Anyone having idea about alternate technology for COM or how COM can be used on MAC OS?
Thanks
Suraj Gupta
|
|
|
|
|
Can any body tell me please the meaning of "class ATL_NO_VTABLE abcclass"
vikas da
|
|
|
|
|
tasumisra wrote: Can any body tell me please the meaning of "class ATL_NO_VTABLE abcclass"
Documentation [^] can.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
ATL_NO_VTABLE is a macro which tells the compiler (if supported) not to generate a vtable for a class. For the Microsoft compiler it expands to __declspec(novtable) .
The Microsoft compiler implements virtual function calls as indirect calls through a table of function pointers, called the vtable. It locates the appropriate vtable through a hidden member in each object of the class called the virtual function pointer or vfptr. In each class's constructor (where the class or any of its bases have virtual functions), the vfptr is initialised to point to that class's vtable. Because C++ says to run each constructor, from base to most-derived class, in turn, at the beginning of executing each constructor the vfptr points to that class's vtable. Ultimately, when all the constructors have run, it points to the most-derived class's vtable.
Calling an abstract (pure virtual, with no implementation) function from a constructor is not allowed. There are conditions - such as if you call a non-virtual function from a constructor which in turn calls an abstract function - where you can accidentally do this. To fail cleanly, Visual C++ generates an R6025 error, 'pure virtual function called'. A pointer to the function that implements this occupies the abstract function's slot in the vtable.
If a class is never actually used as a concrete class, that is, no objects are ever created of that class, only of derived ones, the vtable will never be used and is therefore redundant. To save the cost of setting the vfptr unnecessarily, __declspec(novtable) tells the compiler not to generate this code. In addition, if the compiler and linker options are correct (/Gy for the compiler, and /opt:ref for the linker), the linker will discard the vtable if it's not otherwise referenced. If you do use the class as a concrete class, though, the vfptr will still be pointing to the last base that wasn't marked, or if all bases are marked __declspec(novtable), it will be uninitialised and you'll probably crash or corrupt memory.
ATL does not directly construct objects of your class. Instead, the OBJECT_MAP macros declare instantiations of CComObject using your class (where the template derives from your class). Therefore if you only use your classes with these macros, ATL_NO_VTABLE is safe.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Hello everyone,
I am a php developer, but need to interface a dll with my php project. The code for calling the dll function is given on this site
http://www.rtslink.com/visualbasic.html[^]
I created a 'Standard exe' in the vb6 'New project' menu. Then i simply copy pasted this code on there. When i run the code i get an error ->
'Constant /fixed length string, array, user defined types and declarations are not allowed as public member of the object modules.'
I am not getting a single line of code. Can some one please point out the error and decipher the code for me.
Regards,
Chaitannya
|
|
|
|
|
It appears there's a bug in the MIDL compiler installed with Visual Studio 2008. When it generates proxy routines, it creates code like this:
HRESULT STDMETHODCALLTYPE ITestProxy_Method125_Proxy(
ITestProxy * This,
BSTR *path)
{
CLIENT_CALL_RETURN _RetVal;
_RetVal = NdrClientCall2(
( PMIDL_STUB_DESC )&Object_StubDesc,
(PFORMAT_STRING) &TestProxy__MIDL_ProcFormatString.Format[4500,
( unsigned char * )&This);
return ( HRESULT )_RetVal.Simple;
} Notice the missing right bracket ('] ') on the .Format call? Obviously, this causes a compile error.
Has anybody else seen this, and is there a solution?
For the moment, I'm going to write a post-processor for the MIDL stuff to fix this by hand, but that's a butt-ugly way to deal with it.
Software Zen: delete this;
|
|
|
|
|
I can't reproduce this with the default options, what compile options are you using? What's the exact MIDL source?
The default option has been /Oicf for a while and is recommended for NT 4.0 and later. The documentation doesn't say so, but I believe the table stubs generated by /Oicf are also supported on Windows 95 and 98 if the DCOM updates DCOM95 and DCOM98 are installed. (The Release Notes for DCOM98[^] says "The core functionality and application programming interfaces (APIs) new to Distributed COM are identical in both Windows 95/98 (DCOM98) and Windows NT 4.0/5.0.")
If all of the methods use Automation-compliant types, you can use the Automation marshaller by generating and registering a type library rather than generating custom proxies and stubs.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
/Oicf is the option I use. This source compiled successfully originally under VC6, and has since been ported to VS.NET and VS2003.
Unfortunately the problem seems to be related to the size/complexity of the IDL source. This source is large. There are several interfaces defined, and one interface alone has dozens of methods. I've tried several times to reproduce the problem with a simpler and smaller file with no luck.
Mike Dimmick wrote: If all of the methods use Automation-compliant types, you can use the Automation marshaller by generating and registering a type library rather than generating custom proxies and stubs.
I had a difficult time getting this stuff to work originally. I'm using COM to implement a UI plug-in architecture. Some of the plug-in's are in-process servers, some are out-of-process. I'm hesitant to try and eliminate the proxy DLL. If I remember correctly, I tried to remove the proxy requirement when I originally created the framework, and it was an exercise in frustration.
I've written a little utility to post-process the proxy code and fix the problem. It's annoying, but I've got far bigger fish to land in the boat .
Thanks for the reply.
Software Zen: delete this;
|
|
|
|
|
Well, when you're trying to make calls between different contexts (COM+ contexts in the same apartment, different apartments in the same process, different processes, different machines) you need something to turn the call params into a data structure that can be sent across the contexts and back into a call again. That's what the proxy and stub give you. The Automation marshaller is just a different way of having a 'standard' table-driven proxy and stub - it just uses the type library rather than a custom built DLL (which turns around and passes a table to a library routine).
A possible workaround might be to put the older Platform SDK path earlier in the Executables path than the Windows Vista (6.0A) path. MIDL.exe is really a Platform SDK tool rather than a Visual Studio tool. You could also try the older standalone Windows SDK Update for Windows Vista (here[^]).
Otherwise, if it's a really blocking issue, contact Microsoft support, or if not blocking, post on the Visual Studio Feedback Center[^].
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Thanks for the detailed reply.
I'll take a look at switching to the Automation marshaller when I do the actual conversion. My current effort is more of a survey for when it comes time for our whole team to convert our products from VS2003 to VS2008.
Mike Dimmick wrote: Otherwise, if it's a really blocking issue, contact Microsoft support, or if not blocking, post on the Visual Studio Feedback Center[^].
Microsoft support currently returns zero search results for "MIDL" and "Visual Studio 2008", and the Feedback Center doesn't have any active 'connections' for VS2008.
I don't like having to use one of my MSDN support incidents to report a bug, but that's what I may end up doing.
Thanks again.
Software Zen: delete this;
|
|
|
|
|
Gary Wheeler wrote: I don't like having to use one of my MSDN support incidents to report a bug, but that's what I may end up doing.
They don't announce it officially, but I believe that if they acknowledge that it's a bug with no (easy) workaround, Microsoft PSS will refund the support incident. (I think they charge the cost of the support incident back to the development team.) That's what my contact in Exchange support tells me, anyway.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Hello,
I have created a function in an ActiveX DLL similar to the function below:
Public Function f1(ByRef arr1() As String, ByRef arr2() As Double) As String()
End Function
How do I create a SAFEARRAY in Visual C++ to successfully pass both of these arrays?
Regards,
Mike
|
|
|
|
|
|
The data has been put into the SafeArray. However, when reading the data into the VB ActiveX DLL function, I wrote code to display the contents of the array:
Public Function f1(ByRef arr1() As String, ByRef arr2() As Double) As String()
ShowList arr1
End Function
Private Sub ShowList(ByRef arr() As String)
for i1 = LBound(arr, 1) to UBound(arr, 1)
MsgBox arr(i1)
next i1
End Sub
The program crashes.
Regards,
Mike
|
|
|
|
|
That probably means that SafeArray initialization was wrong on the C++ (client) side. How do you perform that task?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
SAFEARRAY* CreateASafeArray()
{
USES_CONVERSION;
char buffer[20];
HRESULT hr= S_OK;
SAFEARRAY *pSA;
SAFEARRAYBOUND aDim[1];
aDim[0].lLbound= 0;
aDim[0].cElements= 10;
pSA= SafeArrayCreate(VT_VARIANT,1,aDim);
if (pSA != NULL) {
long aLong[1];
for (long l= aDim[0].lLbound; l< (long)(aDim[0].cElements + aDim[0].lLbound); l++) {
VARIANT vOut;
VariantInit(&vOut);
vOut.vt= VT_BSTR;
_ltoa_s(l,buffer,10);
vOut.bstrVal= ::SysAllocString(A2W(buffer));
aLong[0]= l;
if (hr= SafeArrayPutElement(pSA, aLong, &vOut)) {
VariantClear(&vOut);
SafeArrayDestroy(pSA);
return NULL;
}
VariantClear(&vOut);
}
}
return pSA;
SafeArrayDestroy(pSA);
}
void CaxDlg::OnBnClickedButton1()
{
SAFEARRAY *pSA3 = CreateASafeArray ();
}
Regards,
Mike
|
|
|
|