First of all I beg your holy pardon for not understanding where to put this post down, of which I have chosen Miscellaneous section.
I was working with PHP version 5.4.19 and was willing to parse few codes through a .dll file which I would create using Visual C# 2010 Express edition.
So, I started and created a Project using Visual C# 2010 as Class Library. This initially loaded my project and dropped me to Class1.cs file. First I changed the file name to MyClass.cs which contains the following line:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NiladriSen
{
namespace InfoValley
{
namespace Sample
{
public class MyClass
{
protected String myScope;
public void setScope(String scope)
{
this.myScope = scope;
}
public String getScope()
{
return this.myScope;
}
}
}
}
}
The AssemblyInfo.cs file contains the following line implemented:
...
[assembly: AssemblyCulture("en")]
...
[assembly: ComVisible(true)]
...
[assembly: AssemblyVersion("2.3.X.XXXX")]
[assembly: AssemblyFileVersion("2.3.X.XXXX")]
[assembly: NeutralResourcesLanguageAttribute("en-IN")]
From the Project Properties section, I changed the Target Framework from 4.0 to 3.5 Client Profile, and in the signing section I named it as NiladriSen.InfoValley.Sample and then using the gacutil tool I registered it in GAC with the following command:
Quote:
gacutil /i NiladriSen.dll
Note: As my namespace for class MyClass reflects as
namespace NiladriSen.InfoValley.Sample;
should I need to change the Assembly name as
NiladriSen.InfoValley.Sample
?
Finally, when I called this using DOTNET class in PHP as $sample = new DOTNET("NiladriSen, Version=2.3.X.XXXX, Culture=en, PublicKeyToken=XXXXXXXXXXXXXXXX", "NiladriSen.InfoValley.Sample.MyClass"); it threw the following error:
PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80070002] The system cannot find the file specified.' in C:\Users\*******\Desktop\Sample.php:2
If I change the PHP code as $sample = new DOTNET("NiladriSen.InfoValley.Sample, Version=2.3.X.XXXX, Culture=en, PublicKeyToken=XXXXXXXXXXXXXXXX", "NiladriSen.InfoValley.Sample.MyClass"); it threw the following error:
PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80131522] ' in C:\Users\*******\Desktop\Sample.php:2
Question: Is there any way to fix this up? Elaborately, can I use that particular .dll file created using Visual C# 2010 in PHP 5.4.19 at all?
Note:
I am using Vista Home Basic (SP 2), Visual C# 2010 Express edition, PHP 5.4.19, Apache 2.2 & 2.4 versions
I signed this file with no password set at all in Project Properties section.