AXAcroPDF will not load - vb.net

I have a PDF COM control on a Windows Forms Application. The process is simple, a file path is sent to a Sub, it checks if the file exists and if so, loads the file on my PDF control and shows the form. The code is simple:
Public Sub LoadPDF(ByVal pathPDF As String)
MessageBox.Show(pathPDF)
If System.IO.File.Exists(pathPDF) Then
frmPDF.dePDF.LoadFile(pathPDF)
frmPDF.Show()
Else
MessageBox.Show("No image available. Please check FEMA and CAMSIS.")
frmPDF.Hide()
End If
End Sub
This code worked 2 hours ago. The same code still works in other applications (that pull the exact same file path). I have compared designer codes/control properties/etc between the current application and the others. I can't find a difference at all. I have tried completely recreating the form and COM control.
Does anyone know why this may be happening?
My solution:
The reference .dll files were corrupt. I used the solution here C# System.AccessViolationException and System.Runtime.InteropServices.SEHException
to fix it. Everything seems to be running fine for now.

Use this instead
axAcroPDF1.src = PDFPath;
To load your PDF into the control instead of LoadFile.

Related

Word opens for real when trying to fill-in the blanks dynamically?

I'm currently using Word documents as templates where blanks have to be filled dynamically/programmatically in PwoerBuilder.
This has always worked fine until the company moves on Windows 7.
In short, the Word application is opened and made invisible.
Word.Application.Visible = false
Except that sometimes, and I don't know why, once the template is accessed, Word opens itself just as if I had double-clicked the template byself through the Explorer - but I didn't.
So, it asks whether I want to open it in read-only mode, since the application already has a handle on the file. And even if I click [Cancel] not to open the file, Word opens with no document, then the application crashes.
It reports PowerBuilder System Error 35.
Error Number 35.
Error text = Error calling external object function open at line 24 in function of_fusion of object n_cst_9999.
The external object that the application is trying to call a function against is Word.
oleobject lole_word
lole_word = create oleobject
lole_word = ConnectToNewObject("Word.Application")
lole_word.Documents.Open("templatefile.docx")
It may work for a few documents, and after a few, the problem comes up. This is the first time ever I meet with this issue.
I'll be glad to answer anyone's question who's trying to help.
Will, you may try setting DisplayAlerts and FeatureInstall properties on Word Application object.
That hid most of word alerts for us. (The code is from C# project and may not be exactly what you need)
Word.Application.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
Word.Application.FeatureInstall = 0;
You may also try making a copy of the file before opening it to avoid accessing same .docx from different threads - if that may be the case.

System.Drawing.Bitmap error

I have a project with several forms that contain a picturebox (which sometimes contains an image). When I debug my project, I get an error message that says: "System.Drawing.Bitmap". After placing breakpoints in my code, I removed the picturebox from the form. When I go to the next form that contains a picturebox, I get the same error again...
I can't keep deleting all the pictureboxes. I need a solution. Problem is I can't really find any similar problems. I guess there is something wrong with some kind of references of the images or they are not being found...
My project is made for mobile devices / PDA's or Windows CE and written in VB.net.
Are you using the same picture in multiple places? Are the images being disposed or cloned correctly?
If you use the same image multiple times, try calling .Clone (but don't forget to call .Dispose when you are done with the clone)
How are the images being loaded / stored?

Error on Load Event when using My.Settings

I am currently having an issue with the usage of embedded settings in my application. I intend to use them with the form load/closing event, but I am recieving an error like this user:
Error when loading mySettings [Visual basics 2010]
I looked at my settings.vb file and everything appears to be in order, but I am not really sure what could have become incorrect/corrupt because it is all generated when I make changes to the project properties. In order to check if my usage of the settings was correct I created a new project with:
Private Sub Load()
Textbox1.Text = My.Settings.Test
End Sub
Private Sub Close()
My.Settings.Test = TextBox1.Text
End Sub
Everything is working perfectly in the new project, so the error is isolated to my particular project. Has anyone encountered this or have any ideas on how to remedy it?
Thanks for any help!
Exact Same Error from another user:
For those people googling this in the future here is the solution in my case:
Click View Detail and continue navigation through the error detail until you find the path to the app.config file. Once you find it move it to a backup location and run your app again. The file will be regenerated correctly.

VB.NET ~ Sub Routines - can they be saved to a text file and then called?

I have about 100 sub routines that I need to use..I am going to be calling them into a web browser component do get some elements after each web page has completed.
Is it possible to create one sub routine and then has say a streamreader loop through a folder and read each text file in the folder to put the sub into a string?
I would then simply call that one sub into the webbrowser component but I didn't know if this was possible?
There would be about 100 different text files in the folder.
The thinking behind this would be that if I wanted to add more website instructions to the sub or take away from the sub I could just delete a text file.
How would one begin this crazy journey?
Thanks
That isn't really something you would want to do. Its also not possible since vb.net is a compiled language it can't just read the text of the code on the fly and implement it like that.
You are better off investigating another pattern that will meet your needs.
Actually you can programmatically create a vb.net program on the fly. I created a web program which rewrites itself as I see fit. Part of that code adds new subroutines to the same vb.net program. Basically writing more sub routines to itself and then it runs itself again. You can easily store your other subs into txt files and then recall the data later if you wanted. The trick here, however, is that you have to first add the sub routines into an entirely new file, then, when all the writing is done, you can then preform the following:
File.Delete(Server.MapPath("your old file name"))
File.Copy(Server.MapPath("your new file name"), Server.MapPath("your old file name"))
It should be noted that I make web applications, so it doesn't quite work the same. Using asp.net pages, the way I get the new program to run with the new sub routines is to run on the client side code, in which I include a little timed refresh, which fires once the rewriting task is finished. The page then refreshes with the new vb.net back end code in place.
In order to do this for a desktop application or whatever might require something else which I am not aware of.

VB.NET 2005 problems with Designer not being able to process a code line

I have a problem in my project with the .designer which as everyone know is autogenerated and I ahvent changed at all. One day I was working fine, I did a back up and next day boom! the project suddenly stops working and sends a message that the designer cant procees a code line... and due to this I get more errores (2 in my case), I even had a back up from the day it was working and is useless too, I get the same error, I tryed in my laptop and the same problem comes. How can I delete the "FitTrack"? The incredible part is that while I was trying on the laptop the errors on the desktop were gone in front of my eyes, one and one second later the other one (but still have the warning from the designer and cant see the form), I closed and open it again and again I have the errors...
The error is:
Warning 1 The designer cannot process the code at line 27:
Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11
The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. C:\Documents and Settings\Alan Cardero\Desktop\Reportes Liquidacion\Reportes Liquidacion\Reportes Liquidacion\Form1.Designer.vb 28 0
I would back up the designer.cs file associated with it (like copy it to the desktop), then edit the designer.cs file and remove the offending lines (keeping track of what they do) and then I'd try to redo those lines via the design mode of that form.
I would take out the static assignment in the designer to the resource CrystalReport11 and then add a load handler to your form and before setting the ReportSource back to CrystalReport11 do a check
If(Not DesignMode) Then Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11
Here is a mockup..
Public Sub New()
InitializeComponent()
AddHandler Me.Load, New EventHandler(AddressOf Form1_Load)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If (Not DesignMode) Then Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11
End Sub
You should be able to take a backup, clear the lines that are having problems then when you re-open it the designer will fix the code.
The key is that you want to let the designer re-generate, then just validate that all needed lines are there.
That usually works for me, but you just have to be sure to remove all lines that it doesn't like.
I do an easy way; Right Click on the report then choose Run Custom Tool.
Automatically it fixes all problems and working for me, i solve 52 crystal ReportViewer errors.