|
Thanks. Microsoft doesnt like CLI period. Sucks.
Geez..I have been creating so many workarounds.
|
|
|
|
|
Unable to access variable. Suppose I wanted to access a integer array a[12] stored in my Unmanaged class.
I can only declare pointers inside the ref class. So how do I access the integer array from C#. C# only allows pointers as unsafe. I need to check if each a[i] has a value <0. It seems very hard to do this? Any help?
*******************Managed.cpp*********************************
namespace Managed
{
public ref class ManagedCLR
{
public:
ManagedCLR (void)
{
pObj = new UNMANAGEDNAMESPACE.Data();
}
~ManagedCLR(void)
{
delete pObj;
}
void EntryPoint(void)
{
//pass through to the unmanaged object
pObj->EntryPointUnmanged(); //Here the managed program accesses my unmanaged program.
}
private:
UNMANAGEDNAMESPACE.Data *pObj; //Here my Unmanaged Class is referenced through a pointer.
};
|
|
|
|
|
|
Actually, how would I use properties with arrays???????????
|
|
|
|
|
Found a solution.
I did this in the managed.cpp file
namespace Managed
{
public ref class ManagedCLR
{
public:
ManagedCLR (void)
{
pObj = new UNMANAGEDNAMESPACE.Data();
}
~ManagedCLR(void)
{
delete pObj;
}
void EntryPoint(void)
{
//pass through to the unmanaged object
pObj->EntryPointUnmanged(); //Here the managed program accesses my unmanaged program.
}
int ArrayResult(int i)
{
return Unamanaged::Array[i];
}
private:
UNMANAGEDNAMESPACE.Data *pObj; //Here my Unmanaged Class is referenced through a pointer.
};
|
|
|
|
|
|
The horror!! The horror!!
Boris Jabes (MSFT) has just revealed in a VC++ blog post (in the comments no less; I wonder when we'd have found this out if Sunil Joshi had not asked about it) that Visual Studio 2010 Intellisense, you know, that incredibly fast and reliable rearchitecture of Intellisense that we've all been waiting for, will not support C++/CLI!
http://blogs.msdn.com/vcblog/archive/2009/05/27/rebuilding-intellisense.aspx
This is stunning to me. Boris's statement is effectively that "we don't think you spend all that much of your time in C++/CLI anyway!" Puh!
If you are at all invested in C++/CLI, please head over to that blog post and add a comment indicating your displeasure with this disturbing turn of events.
Thanks,
Eric
|
|
|
|
|
Wow, I thought it was just an issue in the beta. No wonder intellisense is faster! it's doing half the work. This really blows (to put it lightly).
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Yeah, that really blows.
A main reason I dropped C++/CLI for new development a while back.
Still use it as little as possible - for interop, but that's it.
Mark Salsbery
Microsoft MVP - Visual C++
modified on Thursday, May 28, 2009 1:55 PM
|
|
|
|
|
Intellisense is for sissys
Real programmers use vi.
BTW today is Friday for me, have a great weekend
|
|
|
|
|
|
BTW, did you see the followup just below about VC10 intellisense. You are getting hooked up baby!!!
|
|
|
|
|
Heh yeah....but like you said, Intellisense is for sissys.
Intellisense won't make it a first=class .net language. I want to see C++/CLI usable
everywhere C# is, with all the same VS tools!
I spend so much more time with C# now, that when I go back to do some C++/CLI,
it feels like I can't do anything....weird
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
*** UPDATE ***
Boris Jabes has now posted a clarification in the comments of the referenced blog post stating that the lack of C++/CLI Intellisense support in Visual Studio 2010 is temporary and will be remedied as soon as possible after Visual Studio 2010 ships. This is certainly an improvement compared to the original statement, which did not say anything about the lack of C++/CLI support being temporary.
http://blogs.msdn.com/vcblog/archive/2009/05/27/rebuilding-intellisense.aspx
|
|
|
|
|
That's a great news. I remember Herb Sutter saying future versions of VS will have good support for C++/CLI. But Boris really surprised me.
|
|
|
|
|
As with all other combinations of C++, C# and different versions of Visual Studio, I suspect I'll be trusting Visual Assist X[^] to provide me with decent Intellisense
They don't yet have VS2010 support, but judging by their track record (I've been using the product for 8/9 years....), they'll have support pretty soon after VS2010 is released.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello
I am trying to convert from "String ^" to std::String on VC++ 2005. I use this piece of code:
std::string s;
String ^ ss = "hello";
s = ss;
I have got the following error:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'System::String ^' (or there is no acceptable conversion)
Any idea?
Thanks
|
|
|
|
|
You need to work with Marshal::StringToHGlobalAnsi
String^ ss = "hello";
const char* characters = reinterpret_cast<const char*>(Marshal::StringToHGlobalAnsi(ss).ToPointer());
std::string s(characters);
|
|
|
|
|
What about FreeHGlobal()? Memory leak?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Forgot about that Thanks
|
|
|
|
|
String ^ss = "hello";
IntPtr ps = Marshal::StringToHGlobalAnsi(ss);
std::string s((char*)ps.ToPointer());
Marshal::FreeHGlobal(ps);
With VS 2008, there's also
#include <msclr\marshal_cppstd.h>
...
String ^ss = "hello";
std::string s(msclr::interop::marshal_as<std::string>(ss));
Mark Salsbery
Microsoft MVP - Visual C++
modified on Thursday, May 28, 2009 5:28 PM
|
|
|
|
|
|
de nada... no problemo
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm trying to hook the ReadFile API like FileMon does.
Do you have an example of ReadFile?
Please help me .....
|
|
|
|
|
Hi all
I have some question dealing with garbage collection and overall performance of native objects created within managec C++/CLI.
1. Consider std::BusinessClass being a native code. I could create an instance within a managed object with "new" (and not "gcnew", I don't want the gc-overhead:
std::BusinessClass* pBs = new std::BusinessClass();
Question: Is the memory allocated here really not managed by the gc? Is anything managed here? Any performance loss compared to this object created within a native code?
2. Is creating the native object within managed code recommended anyway (native DLL -> managed caller)? Or is it recommended to make use of a native wrapper (native DLL -> native Wrapper -> managed caller)?
3. How was memory managed if I had created the object in 1. with "gcnew" and if memory was allocated from within the native object by "new"? What if it wasn't freed after destruction of the object? Memory leak?
4. Is it possible to create a native C++ object in C# similar to the example in 1.? Or do I need to warp a native function around the native class, so that the function can be called by C#?
Thanks for your anwers in advance.
Sincerly
U. Kant
|
|
|
|