note 120185 added to class.dotnet

From: Date: Fri, 18 Nov 2016 21:04:35 +0000
Subject: note 120185 added to class.dotnet
Groups: php.notes 
Request: Send a blank email to php-notes+get-207158@lists.php.net to get a copy of this message
using dotnet with visual studio 2015 (and net framework 4.6.1 but its the same with others). 1) In visual studio 2015, created a library project (in this case a C#) 2) Double click in the project -> build events -> post build "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\gacutil.exe" /i "$(TargetPath)" When the project its compiled, it adds to the GAC automatically. Please changes the bin folder according your installation. 3) in tools -> External tools, add the next external tool Title: Get Qualified Assembly Name Command: Powershell.exe Arguments: -command "[System.Reflection.AssemblyName]::GetAssemblyName(\"$(TargetPath)\").FullName" User Output Windows : checks 4) run tools -> Get qualified Assembly Name and checks the output windows 5) Creates the next class (Class1 may be its already creates) namespace ClassLibrary2 // <-- changes it. { public class Class1 { public string Ping(string t1,string t2) { return "pong "+t1+t2; } } } 6) in php $full="ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=746927f9726d7222"; // its from the output windows $class = 'ClassLibrary2.Class1'; // its the namespace and the class. $stack = new DOTNET($full,$class); $r1="hello"; $r2="world"; echo $stack->Ping($r1,$r2); IMPORTANT NOTE: PHP "caches" the dll library, so every time that the dll library is compiled, the php service should be restarted (restart the apache service). IMPORTANT NOTE 2: May be you should run Visual Studio as an Administrator. ---- Server IP: 72.52.91.14 Probable Submitter: 201.239.81.173 ---- Manual Page -- http://php.net/manual/en/class.dotnet.php Edit -- https://master.php.net/note/edit/120185 Del: integrated -- https://master.php.net/note/delete/120185/integrated Del: useless -- https://master.php.net/note/delete/120185/useless Del: bad code -- https://master.php.net/note/delete/120185/bad+code Del: spam -- https://master.php.net/note/delete/120185/spam Del: non-english -- https://master.php.net/note/delete/120185/non-english Del: in docs -- https://master.php.net/note/delete/120185/in+docs Del: other reasons-- https://master.php.net/note/delete/120185 Reject -- https://master.php.net/note/reject/120185 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#207158) next »