|
Hello hardworkboy,
The assertion failure after the call to CoCreateInstance() could be due to one of many reasons. It is important at this stage to determine what is the value of "hr". We can then proceed to diagnose the problem.
Best Regards,
Bio.
|
|
|
|
|
Dear Bio Liong,
Thank you for your reply.
The hr value is -2147221008. Actually I am using WCE ATL COM AppWizard to create a COM. Then on the class view panel, I "New ATL Object", then I got the interface like "IAdd". In the testing program, I write the following:
CComPtr<iadd> pAdd;
hr = pAdd.CoCreateInstance(CLSID_Add);
here I got the problem.
I am quite unfamiliar with COM creation with ATL. So I may make silly mistakes. I am sorry for that.
Sincerely,
HWB
HWB
|
|
|
|
|
You haven't called CoInitialize for the thread making the call to CoCreateInstance.
If anyone here says they've never made that mistake, I wouldn't necessaraily believe them...
Steve S
Developer for hire
|
|
|
|
|
Hello hardworkboy,
I'm echoing Steve. Yes, the error indicates that CoInitialize() has not been called in the thread that invoked "pAdd.CoCreateInstance(CLSID_Add);".
You can easily determine the meanings of HRESULT error codes using the "Error Lookup" tool (this is included in the "Tools" menu of Visual Studio).
By the way, it is important to call CoInitialize() as it determines the apartment in which the calling thread will live in throughout its lifetime. Every thread in an application needs to reside in an apartment.
Apartments are used to control cross-thread access to COM objects.
Best Regards,
Bio.
|
|
|
|
|
I would also like to point out that you should look at HRESULT values in hexadecimal format. That way they will be much easier to remember, trust me on that one! (But then again, I think that when you start to recognize the HRESULT values by heart, you're probably way too deep into it )
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Thank you, all!
I have add the CoInitialize(NULL) function but this time I got the LNK2019 error which complains __Imp_Coinitialize unreolved symbol. I have tried to add the "Ole32.lib" and the "Objbase.h", still got the same link error.
I am sorry I still need your help.
|
|
|
|
|
At a guess:
First assert (in your code) happened because the object isn't registered properly. Second because object creation failed but you're using "pAdd" anyway.
Steve
|
|
|
|
|
Ok. So I have a web service that supports session state between client calls. Now I'm writing an ATL client that must also support those session. Right now the code that was generated for me via "add web reference" doesn't preserve sessions between calls. I know that a client in C#.NET for the same web service works fine if you give it CookieContainer. How to tell ATL C++ cleint to support sessions?
Please help! Urgent! Very urgent!
Thanks a lot in advance!
|
|
|
|
|
hi all,
I have a ATL ActiveX Control object. In a html page using Object Tag I am able to receive events fired from this ActiveX object.
Now I am trying to instantiate the ActiveX control in a javascript file using the function ActiveXObject(ComponetName.ClassName) but cannot receive any events to the javascript.
pls advise.
Thank you,
Elza
|
|
|
|
|
help, Given
CString=
"key1: value1\r\n
key2: value2\r\n
key3: value3\r\n"
what would be the best way to be able to randomly access it like a map, eg in one call I want to know the value assigned to key3, and another call I want to know the value assigned to key1.
Thanks!
|
|
|
|
|
if you expect a map behavior, why not using one ?
std::map<CString, CString> mapKeyValue;
<font color=green>
mapKeyValue[<font color=gray>"key1"</font>] = <font color=gray>"value1\r\n"</font>;
mapKeyValue[<font color=gray>"key2"</font>] = <font color=gray>"value2\r\n"</font>;
mapKeyValue[<font color=gray>"key3"</font>] = <font color=gray>"value3\r\n"</font>;
<font color=green>
<font color=blue>int</font> iChoice = Rand123(); <font color=green>
CString strRandomValue;
strRandomValue.Format(<font color=gray>"key%d"</font>, iChoice);
strRandomValue = mapKeyValue[strRandomValue];
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
-- modified at 9:31 Monday 5th December, 2005
|
|
|
|
|
Hello everybody,
Could anybody let me know how to use unique member function of list template class in STL? My problem is, I have a C++ class, Complex, which has two data members, real and imaginary numbers. I am using Complex class in creating a list. How can I use unique member function of list class when I have created a list using Complex class?
Grateful to you,
Thanks,
Software Developer
Sanjay Khapre
|
|
|
|
|
list::unique works on sorted ranges, so that might explain why you think it doesnt work.
#include <iostream>
#include <list>
//#include <complex>
using namespace std;
struct Complex
{
Complex(int a, int b): i(a), r(b) {}
int i;
int r;
bool operator < (const Complex&c)
{
if (r != c.r)
return r < c.r;
else
return i < c.i;
}
bool operator == (const Complex&c)
{
return r == c.r && i == c.i;
}
friend ostream& operator << (const ostream&out, const Complex& c);
};
ostream& operator << (ostream&out, const Complex& c)
{
out << "(" << c.r << "," << c.i << ")";
return out;
}
int main()
{
list<Complex > l;
for (unsigned int i = 0;i<10;++i)
l.push_back(Complex(1+i%2,2+(i+1)%3));
copy(l.begin(), l.end(), ostream_iterator<Complex >(cout, "\t"));
cout << endl;
l.unique(); // unsorted list, chances are that no elements are equal to its preceding neighbor
copy(l.begin(), l.end(), ostream_iterator<Complex >(cout, "\t"));
cout << endl;
l.sort();
copy(l.begin(), l.end(), ostream_iterator<Complex >(cout, "\t"));
cout << endl;
l.unique();
copy(l.begin(), l.end(), ostream_iterator<Complex >(cout, "\t"));
cout << endl;
return 0;
}
---
"Man will never be free until the last king is strangled with the entrails of the last priest". -- Denis Diderot
|
|
|
|
|
#include <complex>
#include "boost/assign.hpp"
namespace
{
template <typename T>
struct complex_less : public std::binary_function<std::complex<T>, std::complex<T>, bool>
{
bool operator()(const std::complex<T>& rLhs, const std::complex<T>& rRhs) const
{
//complex numbers don't have '<', force one here
if (rLhs.real() != rRhs.real())
{
return (rLhs.real() < rRhs.real());
}
return (rLhs.imag() < rRhs.imag());
}
};
}
void TestMain()
{
std::list< std::complex<int> > lst;
lst = boost::assign::list_of(std::complex<int>(1, 1))
(std::complex<int>(2, 2))
(std::complex<int>(2, 2))
(std::complex<int>(0, 0));
lst.sort(complex_less<int>());
lst.unique();
#ifdef _DEBUG
std::copy(lst.begin(), lst.end(), std::ostream_iterator< std::complex<int> >(std::cout, " "));
std::cout << std::endl;
#endif
}
|
|
|
|
|
I'm trying for an ATL Component with Containment. but i get the following error.
[error]
error MIDL2025 : syntax error : expecting a type specification near "IIACall"
[/error]
and this comes from the IDL code ,
[IDL]
[propget, id(7), helpstring("property ActiveCall")] HRESULT ActiveCall([out, retval] IIACall* *pVal);
[/IDL]
IDL code displayed is 'Outer' interface.
IIACall* is the pointer to inner interface.
Thanks,
Vivek
oops, i type so bad today
-- modified at 4:50 Wednesday 30th November, 2005
|
|
|
|
|
just it needed a forward declaration
[code]
interface IIACall;
[/code]
thanks a lot alok.
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
Is Mr Alok invisible, or did he email you the answer?
--
Pictures[^] from my Japan trip.
|
|
|
|
|
i think you were invisbile here, or else i'd get a reply from you. i asked alok in mail and he replied me through same. BTW i had a look at your "pictures from my japan trip" that's nice.. but why you didn't display your new japanese girl friend's photo?
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
I see! I've been mostly invisible here because of my recent workload. When I get home at nights I'm either working or just haven't got the will/power.
> but why you didn't display your new japanese girl friend's photo?
My new harem likes their privacy.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Jörgen Sigvardsson wrote: My new harem likes their privacy
Harem... Where it Is...... .. I will slip right under your nose to reach there
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
VivekuniQ wrote: i asked alok in mail and he replied me through same.
But If i remember i replied you on Yahoo Messenger...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Q) When I create any damn ATL Project, using ATL wizard in WINXP/SP2 - I choose simple SIMPLE OBJECT (from object category) after adding methods to interface and compiling and registering using tool->register control OR using REGSVR32.exe "xx.dll", It tells me ok registered successfully. Butwhen i CoCreateInstance(...) it ives me this error. hr = -2147221164 i.e "Class not registered" When i drag it in VB i get error cannot load dll. When i view using ACTIVEX Control Test container, it dosent shows me my class!!! BUThowever if i do use FULL CONTROL using ATL wizard It registers successfully and even i can load it in VB So what mus be the problem with SIMPLE OBJECT
What must be the problem, any genuine solution!!!!
|
|
|
|
|
how do i pass array of values from an ATL(dll) component to a client (VB)??
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
The easiest way is probably as a SAFEARRAY in a VARIANT.
Use the SafeArray* functions to create the SAFEARRAY.
Then put the array into the variant using VT_ARRAY|<array element="" type="" index=""> as the VARIANT type.
HTH.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
In ATL there is a wrapper class for SAFEARRAYs called CComSafeArray. It simplifies using of arrays in COM.
|
|
|
|