|
ralfoide wrote:
public __gc class MyClass
{
public:
void Method(System::String __gc *Param1, int &Param2) {... }
}
The purpose of a ref parameter in C# is where the callee function assigns the value, which is exactly what your void Method(System::String __gc *Param1, int &Param2) function allows to happen to Param2 .
-Nick Parker
|
|
|
|
|
I beg to differ, but my understanding is that a "ref" is used when the called function will modify the value. An "out" seems preferable if the called function is just returning parameters.
My sample prototype was of course simplified. My function returns several parameters, and rather than returning a struct I prefer to use out parameters.
Example of C# prototype I want:
MyClass.MyMethod(string inValue, out int Param1, out int Param2, out int Param3);
So far I got it to work using "ref" if I declare the Param1..3 above using int __gc * in MC++:
This MC++ real prototype in the class library:
MyClass::MyMethod(System::String __gc* inValue, int __gc* Param1, int __gc* Param2, int __gc* Param3);
is seen like this from the C# client:
MyClass.MyMethod(string inValue, ref int Param1, ref int Param2, ref int Param3);
Ideally I'd like out parameters. If not possible, well too bad
R/
|
|
|
|
|
|
Not sure if this will help much, but I think that ref and out perform pretty much the same job, they just set a different kind of contract.
When using out you are effectively saying that the method is responsible for initialising and setting the contents, whereas with ref the calling code is responsible.
What happens if you try and use the out keyword from the C# code? Does the compiler throw up an error?
--
Paul
"Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office."
- David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk
|
|
|
|
|
Why don't you use something like
void foo2( [out] short *value);
|
|
|
|
|
I'm trying to use managed C++ - I know this is the wrong forum but I get no response in the C++ forum.
I'm trying to use old C style structures to read in structured blocks of data from a file and am having no luck. For instance, here's my structure:
[StructLayout(LayoutKind::Explicit)]
__value struct PRE_HEADER
{
public:
[FieldOffset(0)]Byte fileType;
[FieldOffset(1)]UInt32 timeStamp;
[FieldOffset(5)]Int16 numIndexes;
[FieldOffset(7)]Byte padding;
};
Is there some way to read this in, maybe with streams like so:
PRE_HEADER ph;
int blocksize = sizeof(ph);
Byte tmpBuf __gc[] = new Byte __gc[blocksize];
FileStream* fs = File::Open(blah, blah, blah...);
fs->Read(tmpBuf, 0, blocksize);
And then somehow cast "tmpBuf" to be a PRE_HEADER type so I can access the members like you used to be able to do in C/C++??? These managed streams need to have a managed Byte buffer. I tried doing the following:
ph = reinterpret_cast<pre_header>(tmpBuf);
but the compiler isn't happy. I've tried different ways to create the variable "ph" on the managed heap, but because I have a "struc" there's no "new" operator, which I think is causing the unresolved external link errors looking for operator new().
There MUST be some way to do this. It's all so easy with C++ streams. You just make a buffer and pass it to the Stream::Read() function and cast it as your data type and away you go.
Thanks for any help - I"m pulling my hair out with this...
Mark.
|
|
|
|
|
|
Nick.
I tried dynamic_cast but I get a compiler error saying "invalid target type for dynamic cast" (with the capital p
I also tried reinterpret_cast and I get this error:
error C2440: 'reinterpret_cast' : cannot convert from 'unsigned char __gc[]' to 'PRE_HEADER'
I realize a managed array isn't going to be a block of memory - but I can't believe they've left us out in the cold when it comes to this kind of thing. For me it's been the main-stay of my file i/o for data collection because it doesn't tie the file to any language (i.e. through serialization stuff).
Mark.
Mark Malin
(00==[||]==00)
|
|
|
|
|
|
A managed C++ program executes under the .net runtime, so all the rules that apply for normal .net apps, also apply for an application written in mc++, but it gets interesting when you mix both managed and unmanaged code.
If you want to know more on garbage collection/clr, check out msdn, it has tons of docs. on that subject.
Cheers,
Kannan
|
|
|
|
|
I used .NET 2003 VC++ to create a ATL .EXE project. I want add a Web Reference into this project, when I enter the Web Service URL in the "Add Web Reference Dialog", I can get the Web Service Description, but when I click "Add Reference button, I get error message :
error SDL1000 : Not assigned error.
error SDL1002 : failure in generating output file: "WebCtrlService.h"
Who can help me ?
Thanks.
|
|
|
|
|
Does anybody know of any good proposals for a final year undergraduate
computer science project. I would like something i could implement in the
new Visual Studio.net.
James
|
|
|
|
|
i want to know how to use "switch" statement in mfc applications. spcially in the toolbars, where the user can press
one toolbar->circle->draw circle. user can repeat or select new retangle/shape
same toolbar->rectangle->draw recnagle. user can repeat or select new circle/shape
same toolbar->particualr shape->draw that shape. user can repeat or select new retangle/circle
e.g.
switch(toolbar){
case(circle)
{
//draw it}
case (retangle)
{
//draw it
}
case(paricular shape)
[
//draw it
}
}
thanks
shanila
|
|
|
|
|
public __gc class Message
{
private:
TIBRVWrap::MSG __nogc* m_pNativeMsg;
public:
__property void set_ReplySubject(const String* Sbjt)
{
// m_pNativeMsg->SetReplySubject(....);
}
};
public __abstract __gc class Transport
{
public:
Transport(){ }
void Send(Message* msg)
{
// I need to access the msg->m_pNavtiveMsg directly
// How is it possible.
}
};
|
|
|
|
|
public __gc class Message
{
public private:
TIBRVWrap::MSG __nogc* m_pNativeMsg;
public:
__property void set_ReplySubject(const String* Sbjt)
{
// m_pNativeMsg->SetReplySubject(....);
}
};
public __abstract __gc class Transport
{
public:
Transport(){ }
void Send(Message* msg)
{
// I need to access the msg->m_pNavtiveMsg directly
// How is it possible.
}
};
|
|
|
|
|
Sounds like a job for the internal keyword, not sure if it is in MC++ though...
<a TITLE="See my user info" href=http:
|
|
|
|
|
Hello group..
i need a console application in vc ++ to read and write informations in registry..
someone can help me ?
regards
leandro
|
|
|
|
|
|
thanks to see my question~
I hope to use MFC to browse remote directory
my ideal is write one server, one client
when client ask server`s directory
i let server transfer local "BROWSEINFO" to client
and client use it borwse directory function to read
server`s "BROWSEINFO"
but i can`t use socket to transfer "BROWSEINFO" ?
i don`t know what type "BROWSEINFO" is.
or what I think is total worng?
thanks~
Chai-Yuan, Young
chai_yuan@msn.com
|
|
|
|
|
Please use the Visual C++ forum for MFC questions. Here we concentrate on MC++ related isssues.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
you can use the WinSOCK send() to send the BROWSEINFO structure, and use recv to recieve the BROWSEINFO structure from the server.
|
|
|
|
|
hi guys,
I have a doubt..
How to use VC++6.0(Unmanaged classes) in managed C++ Form application?
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
|
Managed C++ executables can have a mixture of native and managed classes. Those classes that are managed have to be prefixed with __gc. The other classes use C++ usual notation.
Be carefull when doing this in dll. Net framework 1.0 and 1.1 have a serious bug when working with mixed code in dlls (dlls may hang - it is called the mixed dll problem). But in executables you can safelly mix code if you take into account the differences between managed and native code.
|
|
|
|
|
I have done lots of reading on the .NET framework and managed C++ but haven't done any development with either. I'm primarily a C++/MFC 6.0 developer and do some ASP/web stuff aside. My web development will move towards ASP.NET. A decision that's a no-brainer to me because of all the benefits and enhancements that come with ASP.NET.
I'm looking for people's opinion on writing shrink wrapped software using MC++ (or C#) and the .NET framework. To do, or not to do? I'm quite stuck on which direction to go, managed code vs. native code, for my next shrink wrapped, desktop application? I don't want to move to .NET just because it's cutting edge, new and exciting.
I don't need any security features provided wit .NET, deployment isn't that difficult now anyway, I don't do mobile devices or multiple platforms, and integration with 3rd party applications is all done with delimited files. From a functional/security standpoint, there's little reason to move to .NET from what I can tell, other than possible productivity gains. Even with productivity gains, I have so much reusable C++/MFC code from other applications, I don't see enhanced productivity being that great.
I've read opinions that say to stay away from MC++ and go C# or VB.NET if developing under .NET. I've read opinions that say stay away from .NET with shrink wrapped, desktop software. Both opinions were shallow with little supporting arguments. I hope to get a more in depth discussion started here.
The fine print:
1) Should shrink wrapped, desktop software be developed using .NET? (i.e. apps like a text editor, graphics editor, or other file-based application.)
2) If so, should reusable C++ code be converted to MC++ or be rewritten using C# or VB.NET?
Thank you for your support. B&J
|
|
|
|