Hello Rick Strahl, Please help me by using wwDotNetBridge in foxpro
do wwDotNetBridge
Local loBridge as wwDotNetBridge
loBridge = CreateObject("wwDotNetBridge","V4")
? loBridge.GetDotnetVersion()
*** Load an assembly from disk
IF !loBridge.LoadAssembly("Spire.Pdf.dll")
? loBridge.cErrorMsg
endif
* I GOT this error
* Es wurde versucht, eine Assembly von einer Netzwerkadresse zu laden,
* was in früheren Versionen von .NET Framework zum Ausführen der * Assembly als Sandkastenassembly geführt hätte.
* In dieser Version von .NET Framework wird die CAS-Richtlinie standardmäßig nicht aktiviert, dieser Ladevorgang kann daher gefährlich sein.
* Wenn Sie nicht beabsichtigen, durch diesen Ladevorgang eine Sandkastenassembly zu erstellen,
* aktivieren Sie den * loadFromRemoteSources-Schalter.
* Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkId=155569".
public loPdfDocument as PdfDocument
loPdfDocument= loBridge.CreateInstance("PdfDocument") && This does not work!!!!, how do I create an Object from the dll ?
loDoc =loPdfDocument.LoadFromFile("Example.pdf")
DO you have any ideas. Thank you
Take a look here:
Most likely you're loading an assembly from a network drive. Try bringing the DLL into the application folder, or if you can't do that set the configuration setting as described in the help topic.
+++ Rick ---
Can't help you with more information.
At a guess I'd say the class you're trying to invoke doesn't have a parameterless contstructor and you have to pass parameters to it when you call CreateInstance()
.
And please look at what you're posting - your message is a garbled mess. Please read on how to format your code on the bottom in front of the Post button.
+++ Rick ---
public loPdfDocument as PdfDocument
loPdfDocument= loBridge.CreateInstance("PdfDocument") && This does not work!!!!, how do I create an Object from the dll ?
loDoc =loPdfDocument.LoadFromFile("Example.pdf")
* How do I config loadFromRemoteSources in VFP ?
**************************************************
*<configuration>
* <runtime>
* <loadFromRemoteSources enabled="true"/>
* </runtime>
*</configuration>
Here is the example in VBNet
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Text
Imports Spire.Pdf
Namespace Extraction
Friend Class Program
Shared Sub Main(ByVal args() As String)
'Create a pdf document.
Dim doc As New PdfDocument()
doc.LoadFromFile("Sample2.pdf")
Dim buffer As New StringBuilder()
Dim images As IList(Of Image) = New List(Of Image)()
For Each page As PdfPageBase In doc.Pages
buffer.Append(page.ExtractText())
For Each image As Image In page.ExtractImages()
images.Add(image)
Next image
Next page
doc.Close()
'save text
Dim fileName As String = "TextInPdf.txt"
File.WriteAllText(fileName, buffer.ToString())
'save image
Dim index As Integer = 0
For Each image As Image In images
Dim imageFileName As String = String.Format("Image-{0}.png", index)
index += 1
image.Save(imageFileName, ImageFormat.Png)
Next image
'Launching the Text file.
Process.Start(fileName)
End Sub
End Class
End Namespace
You need to specify the .NET type with a namespace.
Please take a look at the documentation or the White Paper on how to use wwDotnetBridge.
+++ Rick ---
Sorry, but I don't know,whre is the mistake. Do you have any other ideas, why I got an error by using !loBridge.LoadAssembly()?
do wwDotNetBridge
Local loBridge as wwDotNetBridge
loBridge = CreateObject("wwDotNetBridge","V4")
? loBridge.GetDotnetVersion()
*** Load an assembly from disk
IF !loBridge.LoadAssembly("Spire.Pdf.dll")
? loBridge.cErrorMsg
endif
public loPdfDocument as PdfDocument
loPdfDocument= loBridge.CreateInstance("PdfDocument") && This does not work!!!!, how do I create an Object from the dll ?
loDoc =loPdfDocument.LoadFromFile("Example.pdf")