|
Done that, didnt work For some reason my .h includes's from the CRT have disappeared, but all my own methods are there it would be possible for anyone to execute them via reflection.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I figured it out.
To make a wrapper of this C component (compilied in C) I went and changed all the settings, where all I had to do was a set my wrappers file to compile as /clr and C++. Beautiful The only methods shown are the C methods use by MC++. This way u dont have to mess with pragma blah/that .
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
i use the visual C++, and i want to someone tell me what is the best
Para seguir la trayectoria:
mira al maestro,
sigue al maestro,
camina junto con el maestro,
mira a través del maestro,
conviértete en el maestro
(this is a poor traduction)
To make you trayectory:
Look your master
Follow your master
walk whit your master
look across you master
become in your master
|
|
|
|
|
I am not sure what this has to do with "C and C++ compilers". I agree that [this is poor translation] (this is a poor traduction). I will ask Isrial, are main technition, if he is willing to help, since he is from a country near yours'.
I can not garantee he will be interested.
|
|
|
|
|
Visual C++, claro.
jhaga
(P. Watson)
... and the roar of John Simmons own personal Nascar parked in the garage. Meg flitting about taking photos.Chris having a heated arguement with Colin Davies and .S.Rod. over egian values (or something.) Nish manically typing away at a nearby keyboard. Duncan racing around after his pet rat *censur* Michael Martin and Bryce loudly yelling *censur* C.G. having a fit as Roger Wright loads up Visual Basic. Anna waving *censur* and Deb scoffing chocolates in the corner.
.Good heavens!
|
|
|
|
|
Hi!
I have a class that contains several nested structs:
<code>
public __abstract __gc class Foo
{
public:
__value struct Struct1
{ /** };
__value struct Struct2
{ /** };
__value struct Struct3
{ /** };
__value struct Struct4
{ /** };
[...]
};
</code>
However, that maximum number of nested structs seems to be 17. Whenever I add the 18ths struct, I get an internal compiler error.
Is this a confirmed bug?
Regards,
Andre
|
|
|
|
|
Just test 21 nested structs on VS.NET 2003 Final Beta. It compiles without any problem.
Frankly, working with MC++ is sometimes frustrating. The compiler seems to be a work in progress.
Consider the ff, for instance:
System::String __gc* strTmp1 = String::Format(S"{0}, {1}, {2}",
S"0", S"1", S"2");
System::String __gc* strTmp2 = String::Format(S"{0}, {1}, {2}, {3}",
S"0", S"1", S"2", S"3");
The second strTmp2 will not compile simply because the MC++ does not have support for variable parameters, while C# and even VB.NET supports it.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
I have a managed class and I want to declare a jagged array of doubles as a member. How do I declare this and how do I initialize it? I can do that in C#, but I have syntax problems when it comes to __gc stuff
Thanks!
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
__wchar_t comma __gc[] = {L','};
|
|
|
|
|
Normally you use Array::CreateInstance() method to create the jagged array.
using namespace System;
using namespace System::Collections;
public __gc class Test
{
Test()
{
Int32 lowerBounds[] = {200};
Int32 lengths[] = {10};
_array = Array::CreateInstance(__typeof(Int32), lengths, lowerBounds);
}
private:
Array __gc* _array;
};
You might wish to give a C# example of what you need if the above does not answer your question. Remember you can assign (cast) Array __gc* to [].
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Can anyone tell me waht the difference is between VC++ and Managed C++.
Can anyone also tell what's ATL or COM?
Thanks
|
|
|
|
|
Managed C++.
(in very short)
Is Microsoft extension to the C++ languange to support the .Net framework. The main difference, is that it introduces garbage collection, and other cool stuff.
COM, and ATL, I don't know enough to give an answer.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Managed c++ - the C++ code will be run under the CLR. you can take advantage of the CLR services and be aware of its limitation (for example the CLR control the memory allocation)
COM - is a protocol used by Microsoft in the latest years (until the appearance of .Net) to enable communication, transfer of data and activation of components (DLL, EXE, OCX …) writing in different development tools and languages. As long as the provider and consumer support COM a communication can established between them.
ATL (Active Template Library) - is a library that enable c++ programmer to write components that support COM with less effort. The ATL contain templates that encapsulate many coding issue regarding to COM and let you spend more time on your application rather on COM.
|
|
|
|
|
I got the code as follows:
class A{
int f(); //f defined elsewhere
}
void main()
{
void* p;
p = A::f; //it gives a compiler error
//how to cast f into p?
//My friend did that in asm, however i want an easier way.
}
Thanks in advance
|
|
|
|
|
System::Runtime::InteropServices::Marshal::StructToPtr(ManagedObject,PointerToVoid,true)
|
|
|
|
|
void* p = (void*)(A::f);
C++ compilers are very strict, they want to make absolutly sure you know what you are doing (this is a good thing). If you need to do this you are probubly doing some thing wrong. I recommend that you read up on vetual base classes.
Trust in the code Luke. Yea right!
|
|
|
|
|
I get a runtime error when I cast an object to an interface the class implments. The class and interface are both managed C++, and the cast in done in C#.
I have narrowed the problem down to a simple case:
1) C# constructs an object defined in managed C++
2) C# casts object to a managed C++ interface it implements
3) C# call method on the object after the cast.
If I do this, I get a runtime exception. I have seen an invalid cast exception, and sometimes I get a format exception that says "the format specific is not allowed...". It seems like the runtime gets very confused.
But instead if I do the following;
1) C# constructs a object defined in managed C++
2) C# stores object in variable as its actual type; not the interface
3) C# calls method on class
it all works.
The problem comes when C# casts a managed C++ object to be its interface type (the interface is also defined as a managed C++ interface).
I have not found anyone who has done what I am trying to do, and I have not found any documentaion that talks about this, so perhaps its not recommended.
Does anyone have experience mixing managed C++ and C# with interfaces defined in C++ and casts to the interface being done form C#?
thanks
Bryan
|
|
|
|
|
I got the same experience so i declared the interface in C# Dll.
|
|
|
|
|
So if I declare an interface in C#, can I implement the interface in managed C++ successfully?
|
|
|
|
|
Yes, you can find a sample at http://www.codeproject.com/useritems/SessionState.asp.
look at the source -> tmpSessionSync project.
|
|
|
|
|
I am trying your suggestion. But I have one problem. I have defined an C# interface with a method that returns an object.
How do I define the implementation for this method in C++?
public interface ICOSP_9054_Connection
{
object getConnection( );
}
Originally, when I declared the interface in C++, the method returned a void*. Is there a way to return a void* from a C# method? I can do fine with either approach. The problem is that for some implementors of this method, they will be asking unmanaged C++ code to return an object that I have not defined an interface for so it is easier for me to return a void* (or object).
thanks
Bryan
|
|
|
|
|
public interface ICOSP_9054_Connection
{
object getConnection( );
}
public MyClass : public ICOSP_9054_Connection
{
public:
Object __gc* getConnection()
{
}
};
|
|
|
|
|
I have an app which uses SDI and is written in MFC for its presistence it uses a STL vector. I need to migrate to managed C++ by changing my container to a managed container. I have tried System.Array that didn't work, and either did wrapping the vector. can you please provide a good idea I'm out of ideas.
Sul,R.
Upcoming developer only 2.5 months to go
|
|
|
|
|
System::Array will not provide the STL vector style container. Consider System::Collection::ArrayList. You can derive from the ArrayList and add new methods which match the STL::vector to make the porting easier.
If you still have problems, then post some codes.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Hello All,
I have a standard C++ class with MC++ member defined as
gcroot < System::Drawing::Brush __gc* > m_pDotNetBrush;
Somewhere in the codes, I wish to use the brush and trying to
cast it to the appropriate type:
System::Drawing::SolidBrush __gc* pBrush =
__try_cast < System::Drawing::SolidBrush __gc* >(m_pDotNetBrush);
This, however, generates error in the form:
<br />
error C2682: cannot use __try_cast to convert from 'gcroot < T >' to 'System::Drawing::SolidBrush __gc *'<br />
I tried the other standard C++ casts and all failed with same error.
What is supposed to be done in this case?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|