In visual studio, I create a reference to the Aspose assembly and use the Document class in my code. It looks fine at design-time, but when I go to compile I get the error ‘Type Aspose.Words.Document’ is not defined.’ If I do anything that changes the project file, like add or drop a reference or add a new file, the errors go away… until I try to compile again.
Has anyone else seen this weird behavior and know how to fix it? Here’s my code if it matters, but it doesn’t get much simpler:
Module Module1
Sub Main()
Dim license As New Aspose.Words.License()
license.SetLicense("Aspose.Words.lic")
Dim files = My.Resources.files.Split()
For Each file In files
If file <> "" Then
Dim changed As Boolean = False
Console.Write("Processing " & file & "...")
Dim doc = New Aspose.Words.Document(file)
If doc.Range.FormFields("CurrDate") IsNot Nothing Then
doc.Range.FormFields("CurrDate").TextInputType = Aspose.Words.Fields.TextFormFieldType.RegularText
doc.Range.FormFields("CurrDate").TextInputFormat = ""
doc.Save(file)
Console.WriteLine("done.")
Else
Console.WriteLine("not applicable.")
End If
End If
Next
Console.Read()
End Sub
End Module
I found that it must be because the dll is targeting a different framework than what was specified in the project. I created a new console app that targeted 3.5 instead of 4.0 and it started working.