2012-06-11 33 views
2

這裏被稱爲是在AssemblyInfo.vb中:世界,你好VB.NET類庫,從PHP

Imports System 
Imports System.Reflection 
Imports System.Runtime.InteropServices 

' General Information about an assembly is controlled through the following 
' set of attributes. Change these attribute values to modify the information 
' associated with an assembly. 

' Review the values of the assembly attributes 

<Assembly: AssemblyTitle("ClassLibrary1")> 
<Assembly: AssemblyDescription("")> 
<Assembly: AssemblyCompany("")> 
<Assembly: AssemblyProduct("ClassLibrary1")> 
<Assembly: AssemblyCopyright("Copyright © 2012")> 
<Assembly: AssemblyTrademark("")> 

<Assembly: ComVisible(True)> 

'The following GUID is for the ID of the typelib if this project is exposed to COM 
<Assembly: Guid("bd484c72-e166-4480-a1fd-71ab12e09e25")> 

' Version information for an assembly consists of the following four values: 
' 
'  Major Version 
'  Minor Version 
'  Build Number 
'  Revision 
' 
' You can specify all the values or you can default the Build and Revision Numbers 
' by using the '*' as shown below: 
' <Assembly: AssemblyVersion("1.0.*")> 

<Assembly: AssemblyVersion("1.0.0.0")> 
<Assembly: AssemblyFileVersion("1.0.0.0")> 

而這裏的類:

Public Class Class1 
    Public Sub HelloWorld() 
     MsgBox("hello, world") 
    End Sub 
End Class 

我試圖把DLL後從PHP訪問通過regasm.exe。沒有反應。編輯:現在通過C:\ Program Files文件(x86)\ Microsoft SDKs \ Windows \ v7.0A \ Bin \ NETFX 4.0 Tools \ gacutil.exe運行後,我得到一個強烈的名稱故障,其中我'現在正在工作。]

有沒有人有一個裸露的骨頭,你可以通過PHP 5訪問.NET DLL的另一個詞(如果我沒有弄錯的話,就是「類庫」的另一個詞)?到目前爲止,我是否採用這種方法走上了正確的道路?

這是如何完成的?謝謝你的幫助。

這是PHP代碼BTW:

<?php 
$obj = new COM("ClassLibrary1.Class1"); 
$output=$obj->HelloWorld(); 
echo $output; 
?> 
+0

爲什麼使用COM?爲什麼不使用DOTNET? – Brad

+0

如果您在帖子底部談論我的PHP代碼,謝謝!這看起來不對(不是嗎?),而且在我開始將COM工作開始轉向.NET解決方案之後,我再也沒有這樣做過。你建議應該是DOTNET()?我的其他代碼在樓上怎麼樣,是好的,還是應該有所不同?感謝您的任何指導。 – user225626

+0

是的,我不是COM組件的專家,但在我看來,既然你有一個.NET項目,你可以試着用'DOTNET'加載.NET程序集。 http://php.net/manual/en/class.dotnet.php – Brad

回答

0

這將是正常的PHP到正在運行的服務的Web服務器上運行 - 除非你已經經歷了許多籃球躍升,這些無法與桌面進行互動,因此無法顯示您的MessageBox