Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - C++/CLI convert existing application do managed code -


i've got existing application written in borland c++ builder. client wants rewritten in c#/wpf. requires lot of work , complex task because need rewrite whole (huge) algorithm. thinking of way reuse code , able create gui in c#/wpf. possible? easy? how can make c++ classes visible .net ?

if give me brief answers links/examples grateful.

you can wrap old c++ code in c++/cli wrapper , build dll file. should visible in .net project.

depending on algorithm/function structure, may change little, basic form, , way did this, following. keep in mind basic example, tried include key points:

1. define cli wrapper

using namespace system;  #include "myalgorithmclass"  public ref class mycliwrapperclass //the 'ref' keyword specifies managed class { public:      mycliwrapperclass(); //constructor      //function definitions same, though types,     //like string, change little. here's example:     string ^ getastring(); //the "string" .net "system.string" , ^ sort of pointer managed classes      //int, double, long, char, etc not need specified managed.     //.net code know how handle these types.      //here want define functions in wrapper call     //the functions un-managed class. here examples:     //say functions in algorithm class int func1, double func2, , std::string func3:     int func1();     double func2();     string ^ func3();  private:     //all private functions , members here     myalgorithmclass algor; }; 

2. implement wrapper class

using namespace system; #include <string> //for string function ex. below #include "myalgorithmclass"  mycliwrapperclass::mycliwrapperclass() {     algor = myalgorithmclass(); //create instance of un-managed class }  int mycliwrapperclass::func1() {     return algor.func1(); //call un-managed class function. }  double mycliwrapperclass::func2() {     return algor.func2(); //call un-managed class function. }  string ^ mycliwrapperclass::func3() {     //converting std::string system.string requires conversion     //but i'm sure can find somewhere on google or here on      string ^ mystring = "";     std::string myunmanagedstring = algor.func3(); //call un-managed class function.      //convert myunmanagedstring std::string system.string here      return mystring; } 

after write wrapper class , compile class library can create reference .dll file in c# project , c# should see managed wrapper class , public functions.

another thing note if creating new managed objects in c++ use keyword "gcnew" instead of "new". new string string ^ somestring = gcnew string();

finally, here links things cli may help:

cli - wikipedia
cli - code project
cli - functionx


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -