C++/CLI: Object Clone

Basically, Clone can be implemented either as a deep copy or a shallow copy. In a deep copy, all objects are duplicated; whereas, in a shallow copy, only the top-level objects are duplicated and the lower levels containreferences.

But here we work under System::Runtime::Serialization::Formatters::Binary

Step 1: Serialize your object
Step 2: And then Deserialize  your object
Step 3: Close you MemoryStream instance
Step 4: Return Object
That’s it..

So here is the method,

public: System::Object^ Clone(System::Object^ apObj )
{
MemoryStream^ ms = gcnew MemoryStream();
BinaryFormatter^ bf = gcnew BinaryFormatter();
bf->Serialize( ms, apObj );
ms->Position = 0;
System::Object^ obj = bf->Deserialize( ms );
ms->Close();
return obj;
}

This is most fast way to clone your object very easily. So fulks ..

enjoy 😉

Communicating with C++/CLI to ActionScript

Inspired by Gabe Wishnie
As a matter of fact, i was tried to implement C# and the Flash Player 8 External API with my C++/CLI project. However,  i was using Visual Studio 2005.
My main goal of this post is to aware what is the most basic part to implement this kind of staff in project.
Troubleshooting
1. To begin porting over the FLVPlayer it will be batter to use the most updated flash player.
2. Most of the time people ask about the problem with CallFunction method as it said this method is not a member.
3. If this kind of ambiguous problem faced then re-check your Flash Virsion. Flash 6,7 will the main cause of this error. Upgrade it into 8, 9 or 10
4. In ActionScript you must add these lines first

import flash.external.ExternalInterface;
ExternalInterface.addCallback("YourMethod", null, YourMethod);
function YourMethod(uri:String):Void
{
if(uri == "TANVEER")
{
// something my logic will be applicable;
}
}

5. In C++/CLI

private: AxShockwaveFlashObjects::AxShockwaveFlash^ mpAxShockwaveFlashBee;
private: System::Void mpButtonClick_Click(System::Object^ sender, System::EventArgs^ e)
{

mpAxShockwaveFlashBee->CallFunction(“<invoke” + ” name=\”loadAndPlayVideo\” returntype=\”xml\”><arguments><string>TANVEER</string></arguments></invoke>”);

}

6. Done! It is now that easy to pass data back ActionScript and C++/CLI.

My Source code:needbee.rar.pdf

rename it as needbee.rar

error PRJ0002 : Error result -1073741701 returned from ‘C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\resgen.exe’

😉 SOLVED!!

While working with C++/CLI .NET  in Visual Studio 2005 and suddenly i got this compilation error.

error PRJ0002 : Error result -1073741701 returned from ‘C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\resgen.exe’

I don’t know why? but after googled some while i found that it was because of  some virus. huh! 😦

But I solved this in my style. What i did just rreplace the file Resgen.exe in the same folder.

Just download this resgenexe2 and rename it as ResGen.exe and replace the file ResGen.exe file into your /*C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin*/ directory if you have this compilation problem.


enjoy 😉

%d bloggers like this: