|
I recommend Visual Assist .NET if you find Ms intelisense doesn't make sense to you. It is a nifty tool.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi, anyone can convert this C# statement to C++?
object [] objArgs = new object[] {123,23,45,265};
The following didn't work:
Object * args[] = new Object[] {1,2,3,4,5};
Thanks.
norm
|
|
|
|
|
|
|
Just so you know how Tom's example works - you must box value types before you pass them as objects, because object is a reference type. C# does this for you, but MC++ doesn't.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
What do you mean "object is a reference type"?
I C++:
int SomeFunc(int ¶m);
param is passed to SomeFunc by "reference" as opposed to "by value". But what's a "Reference Type"?
norm
|
|
|
|
|
Different usage. In .NET terms, a reference type is one that is allocated on the CLR heap (and not the local C++ heap). A value type is one that is allocated on the local stack. A literal number as you had is a value type and has to be boxed into a reference type before it can be used in a managed function.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
it's expecting an Object i suppose. I read __box docs. Actually I came across it before, but forgot about it. Thanks anyway.
norm
|
|
|
|
|
Playing with ATL server and RCW/Interop:
QUESTION 1. Can you pass custom defined object through COM interface? If you "Add Function" (right click classview on an ATL object/class), "Add Member Function Wizard" pops up. One can "choose" parameter type from the list of options available.
But what if I want to pass across interface the following:
a. A result set?
b. A user-defined class:
CMyClass
{
};
How can I do that? And can I do that in the first place?
QUESTION 2: What's the diff between "retval" and "out":
[propget, id(3), helpstring("property ComputerName")] HRESULT ComputerName([out, retval] BSTR* pVal);
"retval" IS "out" isn't it? If pVal is passed as a pointer, why do you need to marked the parameter as [out][retval]?
QUESTION 3: With ATL server projects, how can you add multiple interface? When you add "ATL simple object", the first interface is created for you by the wizard. Do you have do add to IDL file manually for subsequent interfaces? Is all that you need to do is to add to IDL? Any additional steps?
QUESTION 4: I tried to get a "double" across interface - but it always return "zero" to the client for some reason:
[id(1),helpstring("method GetRandNum")] HRESULT GetRandNum([out,retval] DOUBLE *RandNum);
STDMETHODIMP CCATLSimple::GetRandNum(DOUBLE* RandNum)
{
// TODO: Add your implementation code here
srand( (unsigned) time(NULL) );
double randy = rand();
RandNum = &randy;
return S_OK;
}
What could be the problem?
Thanks a lot, that's a long posting.
|
|
|
|
|
I am developing a game.Now my problem is that when the stick hits the balls lying on table balls are rotating and not moving.I want them to move and get into holes in the table.I am doing this in graphics in C.Can somebody tell me what should i do to solve this problem
Thanks
|
|
|
|
|
|
|
|
|
Take your right hand out of your pocket and use left hand from now on.;P
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
|
Hello everyone!
I hope that I won´t be kicked out for asking the same question again and again until I get it to work. But here goes:
I´m developing a managed C++-web Service and my problem
occured months ago when I tried to pass binary files as dataset
between the client and the service. I then got the advice to
use DIME and recently downloaded WSE 1.0 SP1.
I read an example in C# and tried to convert the code to
c++. But it don´t get it to work.
C#
DimeAttachment attachment = new DimeAttachment("application/octet-stream",
TypeFormatEnum.MediaType, ms);
HttpSoapContext.ResponseContext.Attachments.Clear();
HttpSoapContext.ResponseContext.Attachments.Add(attachment);
C++ (I´ve tried this, and similar)
DimeAttachment* attachment;
attachment = new DimeAttachment("application/octet-stream", TypeFormatEnum::MediaType, ms);
HttpSoapContext* hsc;
hsc->get_ResponseContext()->get_Attachments()->Clear();
hsc->ResponseContext->Attachments->Add(attachment);
This will compile, but when I run I get the error
"Object not set to an instance.." on the ...->Clear(); row.
If I then try to instance the object;
HttpSoapContext* phsc = new HttpSoapContext();
or
SoapContext* sc = new SoapContext();
i get the error C2512 "no deafult constructor" when I compile.
What can be wrong? Are there som arguments missing;
Intellisense doesn´t detect any. Are there some error in
the config-files?
With the very highest regards
PS*************************************************
Well actually, I also can´t get a C#-version to function.
I downloaded Roman Kiss-example
"Using WSE-DIME for Remoting over Internet"
http://www.codeproject.com/cs/webservices/remotingdime.asp
...allthough I did everything according to the book I kept on getting
the error .FileLoadException "The assembly manifest definition [name]
does not match the assembly reference".
DS**************************************************;);)
Daniel
|
|
|
|
|
Instead of
adaoja wrote:
HttpSoapContext* hsc;
hsc->get_ResponseContext()->get_Attachments()->Clear();
put
<br />
HttpSoapContext::get_ResponseContext()->get_Attachments()->Clear();<br />
|
|
|
|
|
Thank you Nemanja
But, the problem is (as i wrote previously) not really that codesnippet but why I can´t make an instance of the HttpSoapContext-object. And why do I have to? In C# there is no need for a
HttpSoapContext variable = new HttpSoapContext();
statement.
If I use your codesnippet it works for the compiler but not when I run the project (much like when I use pointers like above). I get the error "Object not set to an instance..."
and if I try to make an instance the compiler complains with C2512 "No deafult constructor available".
This is what confuses me.
With the highest regards
Daniel
|
|
|
|
|
You don't need to make an instance. get_ResponseContext() is a static method.
adaoja wrote:
If I use your codesnippet it works for the compiler but not when I run the project (much like when I use pointers like above). I get the error "Object not set to an instance..."
Would you show me exactly what code did you try to compile and what is the error you get?
|
|
|
|
|
If you take a look at This MSDN article[^], you'll see that
HttpSoapContext<br /> is a "utility" class that contain only two static members. You can't instantiate objects of that class.
|
|
|
|
|
Hi Nemanja
I do understand that, but why can´t I run the program? Why do I at that line get a "Object not set to an instance" - error. It doesn´t make any sense to me.
With the highest regards
// Daniel
|
|
|
|
|
Maybe get_ResponseContext() or get_Attachments() return null. Why don't you break this big line and check for null?
|
|
|
|
|
woops!
That is true, they both return null.
Now I´m even more lost.
With the highest regards
// Daniel
|
|
|
|
|
I guess you need to put a complete codes for ppl to study your problem. It could be just some typos or small problem.
Like namespace stuff or anything. Having too short of explanation of your problem will only return less understandable answer. (i learn this from someone in codeproject)
Sonork 100.41263:Anthony_Yio
|
|
|
|