2. Open the project properties, click "Apply" on the left (the first tab), and then click the assembly information button. In the pop-up dialog box, you must check: make assembly COM visible! Otherwise, COM will not be able to access this dll. (you can also write [ComVisible(true)] in the class declaration in the code, and the effect is the same, so you need to add using system. Runtime.interopservices quotation)
PHP calls dll class library method developed by C#
3. Create a strong name signature file and use the
Use vs.net's "Virtual Studio". Net tool "->; At the command prompt of Vistual Studio. Net, enter sn -k d:HelloWorld.snk and press enter to create a strong name signature file.
Open the project's properties, click the signature assembly on the left, and select the HelloWorld.snk file just created in Choose a strong name key file:
4. Create a class library and compile it into a dll
The copy code code is as follows:
Namespace HelloWorld
{
//[COM Visible(true)]// Or check "assemblycom-visible" in the application-assembly _ information dialog box;
Hello, open class
{
Common string writing ()
{
Return "hello world";
}
}
}
5. Find the dll folder path, and then use vs.net's Vsitual Studio. Net tool "->; Vistual studio Net command prompt
Enter the dll folder and enter:
The copy code code is as follows:
Regasm HelloWorld.dll < input >
At this time. The. net assembly of this. Dll will beCome a standard Com component, but it can't be used yet, so it must be turned into a global com component.
Add an assembly to the global assembly cache
Enter the prompt window and enter:
The copy code code is as follows:
gacutil/I hello world . dll & lt; Enter >
At this point, your dll is copied to the global assembly cache. In other words, this dll component can be used on any hard disk of this computer.
Without strong name signing, this step will prompt that the loading failed: