Edit report at https://bugs.php.net/bug.php?id=55847&edit=1
ID: 55847 Comment by: user at kkdf2 dot sakura dot ne dot jp Reported by: cosmin dot nicula at gmail dot com Summary: DOTNET .NET 4.0 GAC new location Status: Open Type: Bug Package: COM related Operating System: Windows XP SP3 PHP Version: 5.3.8 Block user comment: N Private report: N New Comment: I'v tested regasm. The class library built on .NET 4.0 can be loaded and accessed via "new COM". Also it seems that .NET runtime 2.0 and 4.0 can work separately in one process memory. t.php --- <?php $v20 = new COM("ClassLibrary1.Class1"); print $v20->Hello(); print "\n"; $v40 = new COM("ClassLibrary40.Class1"); print $v40->Hello(); print "\n"; ?> --- Output of t.php --- Hello from v2.0.50727 with System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Hello from v4.0.30319 with System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 --- Class1.cs in ClassLibrary1(.NET 3.5) --- using System; using System.Runtime.InteropServices; namespace ClassLibrary1 { [ComVisible(true), Guid("ddfe022c-eaf7-4a6a-9429-0f1846af7be7")] public class Class1 { public string Hello() { return "Hello from " + System.Reflection.Assembly.GetExecutingAssembly().ImageRuntimeVersion + " with " + typeof(String).AssemblyQualifiedName; } } } --- Class1.cs in ClassLibrary40(.NET 4.0) --- using System; using System.Runtime.InteropServices; namespace ClassLibrary40 { [ComVisible(true), Guid("ebd2758d-96b9-4b20-afaa-d67c2c99998f")] public class Class1 { public string Hello() { return "Hello from " + System.Reflection.Assembly.GetExecutingAssembly().ImageRuntimeVersion + " with " + typeof(String).AssemblyQualifiedName; } } } --- Previous Comments: ------------------------------------------------------------------------ [2013-02-18 12:34:15] user at kkdf2 dot sakura dot ne dot jp Hmm, regasm and using COM instead of DOTNET may be likely workaround to solve CLR version issue. Check the note at dotnet_load function: http://www.php.net/manual/en/function.dotnet-load.php ------------------------------------------------------------------------ [2013-02-17 13:59:39] user at kkdf2 dot sakura dot ne dot jp Is it a problem on php settings, or need an extension to php dotnet? If it is as a new feature, how about access to the newer .NET runtime? new DOTNET4("...") or com.dotnet_runtime = "v4.0.30319" ; in php.ini new DOTNET("...") Have a good idea? Thanks ------------------------------------------------------------------------ [2011-10-04 16:23:44] cosmin dot nicula at gmail dot com Description: ------------ The DOTNET class in PHP seems to "look" only for CLR 2.0 assemblies and not for CLR 4.0 assemblies. Since with .NET Framework 4.0, GAC was split in two, one for each CLR. The CLR for both .NET Framework 2.0 and .NET Framework 3.5 is CLR 2.0, and the CLR for .NET Framework 4.0 stands separately, not allowing CLR 2.0 applications to see CLR 4.0 assemblies. The CLR 2.0 assemblies directory is located in: %windir%\assembly, whereas the CLR 4.0 assemblies directory is located in: %windir%\Microsoft.NET\assembly. After installing an assembly in the GAC, if the targeted .NET Framework is 2.0 or 3.5, the DOTNET constructor correctly identifies the Strong Named assembly. If the targeted .NET Framework is 4.0, the DOTNET constructor throws an exception "PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80070002] The system cannot find the file specified.", although the assembly is correctly installed in the GAC under %windir%\Microsoft.NET\assembly directory with the gacutil tool. Test script: --------------- Test case1: install an assembly mylibrary.dll in the GAC with targeted .NET Framework 2.0 or 3.5. %ProgramFiles%\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe C:\mylibrary.dll The following PHP snippet (replace ... with relevant info) correctly identifies the Strong Named assembly MyLibrary located in the %windir%\assembly folder. <?php $myDotNetObject = new DOTNET('MyLibrary, Version=..., Culture=neutral, PublicKeyToken=...', 'MyLibrary.MainFunction'); ?> Test case2: install an assembly mylibrary.dll in the GAC with targeted .NET Framework 4.0. %ProgramFiles%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\gacutil.exe C:\mylibrary.dll The following PHP snippet (replace ... with relevant info) does not identifies the Strong Named assembly MyLibrary located in the %windir%\Microsoft.NET\assembly folder. <?php $myDotNetObject = new DOTNET('MyLibrary, Version=..., Culture=neutral, PublicKeyToken=...', 'MyLibrary.MainFunction'); ?> Expected result: ---------------- The following PHP snippet (replace ... with relevant info) should correctly indentify the Strong Named assembly MyLibrary located in the %windir%\Microsoft.NET\assembly folder. <?php $myDotNetObject = new DOTNET('MyLibrary, Version=..., Culture=neutral, PublicKeyToken=...', 'MyLibrary.MainFunction'); ?> Actual result: -------------- The DOTNET constructor throws an exception "PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80070002] The system cannot find the file specified." ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55847&edit=1