Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

Object reference error while including non pure mode dll #66

Open
rushi216 opened this issue Apr 18, 2016 · 2 comments
Open

Object reference error while including non pure mode dll #66

rushi216 opened this issue Apr 18, 2016 · 2 comments

Comments

@rushi216
Copy link

I want to consume simple php library in c# application, for that I have simple php class like below,

class SampleObj
{
    public $Message = "Hello world!";

    function Write($arg)
    {
        echo $arg."\n";
    }

    function Add($a, $b)
    {
        return $a + $b;
    }
}

I am converting this into dll using below command

phpc /target:dll /out:objects.dll objects.php

Now i am using it in c# console application by below code

ScriptContext ctx = ScriptContext.CurrentContext;
ctx.Output = Console.Out;
ctx.Include("objects.php", false);

I have also added below in App.config file and gave reference to objects.dll in project references

<phpNet>
    <classLibrary>
      <add assembly="mscorlib"/>
      <!--<add assembly="objects, Version=1.0.0.0" />-->
      <add url="objects.dll" />
    </classLibrary>
</phpNet>

Still I am having exception like below

{"Library assembly 'file:///C:/CSharpConsole/bin/Debug/objects.dll' could not be loaded. Object reference not set to an instance of an object."}

at PHP.Core.AssemblyLoader.Load(String assemblyName, Uri assemblyUrl, LibraryConfigStore config)
at PHP.Core.PhpConfigurationContext.LoadLibrary(String assemblyName, Uri assemblyUrl, String sectionName, XmlNode node)
at PHP.Core.LibrariesConfigurationList.LoadLibrariesNoLock(Func5 callback, Action1 parseSectionCallback)
at PHP.Core.ConfigurationSectionHandler.GetConfig(ApplicationContext appContext, String sectionName)
at PHP.Core.Configuration.Load(ApplicationContext appContext)
at PHP.Core.ScriptContext..ctor(ApplicationContext appContext)
at PHP.Core.ScriptContext.CreateDefaultScriptContext()
at PHP.Core.ScriptContext.get_CurrentContext()
at CSharpConsole.Program.Main(String[] args) in C:\Users\rushi.PROMACT\Downloads\ducktyping\CSharpConsole\Program.cs:line 28
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

What could be the issue?

@jakubmisek
Copy link
Member

Can you please debug it so we can see the full stacktrace?

@bfistein
Copy link
Contributor

@rushi216 Phalanger's development is mostly discontinued in favor of PeachPie, the more modern compiler and runtime that also targets .NET Core. Please feel free to give that a try.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants