Visual Studio for application insider 2
Of course, we will not compile and run every time. This is not our intention. Using the getcompiledstate of the ivsasite interface, we can mount the file in the compiled PE file and debugging information file.
Public sub getcompiledstate (byref PE () as byte, byref debuginfo () as byte) implements Microsoft. VSA. ivsasite. getcompiledstate
End sub
The implementation of this process has two parameters: the binary representation of the PE file and the debug information. To put it bluntly, the first file is the binary value of the DLL, the second file is the binary value of the PDB file.
How to obtain the compiled PE file and debugging information file
This process is mainly implemented using the savecomiledstate method of vsaengine. After compile is correct
If m_vsaengine.compile () then
M_vsaengine.run ()
End if
Dim PE () as byte
Dim PDB () as byte
M_vsaengine.savecompiledstate (PE, PDB)
Next, it's about writing binary files.
Dim FS as new filestream ("C: \ test. dll", filemode. Create)
Dim BS as new binarywriter (FS)
BS. Write (PE)
FS. Close ()
BS. Close ()
FS = new filestream ("C: \ test. PDB", filemode. Create)
BS = new binarywriter (FS)
BS. Write (PDB)
FS. Close ()
BS. Close ()
Next, we switch to the class implementing ivsasite. In this example, myvsasite is used. We implement the getcompiledstate method.
Public sub getcompiledstate (byref PE () as byte, byref debuginfo () as byte) implements Microsoft. VSA. ivsasite. getcompiledstate
Dim FS as filestream = new filestream ("C: \ test. dll", filemode. open)
Dim BS as binaryreader = new binaryreader (FS)
Pe = BS. readbytes (FS. length)
FS. Close ()
BS. Close ()
FS = new filestream ("C: \ test. PDB", filemode. open)
BS = new binaryreader (FS)
Debuginfo = BS. readbytes (FS. length)
End sub
When you call the run method of vsaloader, vsaloader calls the getcompiledstate method of its site object to obtain data.
This is an example of a call.
M_vsaengine = new Microsoft. VSA. vsaloader
M_vsaengine.rootnamespace = "test"
M_vsaengine.rootmoniker = "test: // project1"
M_vsaengine.site = new myvsasite
M_vsaengine.run ()
Dim ARGs () as object = new object () {"jjx "}
Invoke ("testclass. Hello", argS)