|
Which of these formats[^] are you using, and what is the exact content of your parameter?
The best things in life are not things.
|
|
|
|
|
Hi
I think it would be easier if I show you the relevant code snippet to see if you can assist me:
m_dispatch = new COLeDispatchDriver();
COleException comError;
if (m_dispatch->CreateDispatch(_T("99AA66456-082d-5b87-0df-51705603gdbd"), &comError))
{
//Do some stuff here
}
else
{
//trap error here
}
What I am seeing is that when it reaches the if condition it jumps to the else part an I see the error message "Invalid class string". From the examples I have seen I thought passing in the GUID in this way is correct. Is it?
|
|
|
|
|
If you look again at the link I gave you, the first parameter (in your case) needs to be a REFCLSID when providing the GUID of a registered class, whereas you have provided a string. You can always use CLSIDFromString() [^] function to do the conversion for you.
BTW when posting code snippets please use the <pre></pre> tags around it to ensure formatting is retained.
The best things in life are not things.
|
|
|
|
|
Sorry, but I must be misunderstanding this because I am unclear what you mean.
I searched for the dll in regedit and found the progid folder. Taking the name that was there along with the period for version 1 it was still throwing the same error.
For instance my test dll I have called TestCSharp that has a class called Test. This is shown in the ProgId folder as TestCSharp.Test. I have placed this as the parameter with period 1.
So, I could do with a little bit of helping hand here.
Thanks
|
|
|
|
|
I have never used the program id, only GUIDs; try what I suggested as it should work.
The best things in life are not things.
|
|
|
|
|
Hi
Sorry for not getting back to you, but I did use your solution and yes you are right it did work. Please excuse me but I am very new to C++!!
However, I have hit another problem whilst I can call my C# COM object it throws an error it says "the file or assembly xxxxxx cannot be loaded or one of its dependencies. The file sepecified can be found". In my C# COM object I am referencing another class, which itself references another class. When I compiled the C# COM Object, the bin file has the other classes as dlls are present.
What am I doing wrong here? I have to be careful here because the referenced referenced class is used elsewhere in the other project. So, I am not sure whether adding a strong key and registering it would break the program elsewhere.
Can you help?
Thanks
|
|
|
|
|
I'm not sure what the issue is here, but it sounds like you have some files missing, or not installed in the correct directories for the Windows loader to find them when they are called. You may also like to consider trying to simplify the structure of your application if at all possible.
The best things in life are not things.
|
|
|
|
|
I'm opening a Modal Dialog inside a Modal Dialog. While destroying the second Dialog, application crashes at the following assert condition:
ASSERT(::IsWindow(m_hWnd))
in the file afxwin2.inl.
How to destroy a Modal Dialog which is popped up inside another modal Dialog?
|
|
|
|
|
pix_programmer wrote: How to destroy a Modal Dialog which is popped up inside another modal Dialog?
It typically "destroys" itself by the user clicking the OK or Cancel button, or pressing the Esc key.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
This ASSERT is telling you the window doesn't exist anymore, like it was already suggested, modal dialogs don't typically get manually destroyed (although they can be).
|
|
|
|
|
Call EndDialog() method to have the second dialog destroyed properly.
onwards and upwards...
|
|
|
|
|
is there a way I can make this code say "I'm Base!"?
class CBase
{
public:
virtual void testApp()
{
printf("\nI'm base");
}
};
class CDerived : public CBase
{
public:
void testApp()
{
printf("\nI'm derived");
}
};
int _tmain(int argc, _TCHAR* argv[])
{
CBase* cp = new CDerived();
cp->testApp();
return 0;
}
|
|
|
|
|
Smith# wrote: is there a way I can make this code say "I'm Base!"?
You mean other than:
CBase* cp = new CBase(); There's also:
void CDerived::testApp()
{
CBase::testApp();
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
You should have probably posted this as an answer instead of "general"
|
|
|
|
|
David is correct, that's the way to do it, if you don't like his options, then you probably shouldn't have made it virtual, if its not virtual, then the call gets evaluated at runtime according to the pointer.
if not virtual...
CBase* cp = new CDerived();
cp->testApp();
((CDerived *)cp)->testApp();
..you just have to know exactly what it is you want.
|
|
|
|
|
So once we have said virtual, it's dead No? to access the base? Not even a hack available to do that? may be through manipulating vptrs?
|
|
|
|
|
Its not dead, its just the whole purpose behind the "virtual" keyword... that the base method can be overriden... stefan's solution probably works as well, but again, you're overriding a behavior that is designed.
|
|
|
|
|
...and by the way, the derived class doesn't HAVE to override a virtual method in the base, its optional, you only HAVE to override pure virtuals.
|
|
|
|
|
See my answer below: you can still call methods from the base class(es) even if the pointer you use to call it points to a class that has overridden that implementation:
CBase* pbase = new CBase;
CDerived* pDerived = new CDerived;
pbase->testApp();
pDerived->testApp();
pDerived->CBase::testApp();
You can invoke methods of base classes by adding the name of that class, separated by '::' to the name of the function you want to call. In doing so you ignore the virtual function table for that call only. You can freely mix calls of that type with normal calls that use the virtual functions, as you can see in the example above.
|
|
|
|
|
This should do it. Although I'm not at all sure why you'd want that.
int _tmain(int argc, _TCHAR* argv[])
{
CBase* cp = new CDerived();
cp->CBase::testApp();
return 0;
}
|
|
|
|
|
because the intellisense hides this from me.
|
|
|
|
|
this isn't what you'd call normal use...
|
|
|
|
|
It is ok using debug, and run new byte for 59 time ok for release, but the 60th, it faluts showing not enought memory, but I print the value that will be new is 2544
Like this:
void MallocSize(int iMalSize)
{
....
pData = new BYTE[iMalSize];
....
}
void AddFeature()
{
....
for(int i=0; i<3000; i++)
MallocSize(Sizet);
....
}
I try many time but each stop at the 60th, and the value is 2544 Byte
Runtime Lib:Multi-threaded DLL (/MD)
Used memory is 1.02G
and the program is 200MB
Total system memory is 2GB.
Does anyone know what is the problem?
|
|
|
|
|
You are allocating SizeT bytes of memory 3000 times, correct? So what is the value of Sizet ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
good question...
|
|
|
|