Problems with the new Aspose.Words version (3.5)

Hi,

I was using the Aspose.Word version, and now I've upgraded to the Aspose.Words 3.5 version, but I'm having some problems.

When I create a new document instance (Aspose.Words.Document) and I sent in the parameter a document model, It returns an error: Unknown file format.

Do you know what is this? The new Aspose.Words works with the Document interface such as the Aspose.Word?

Thanks for your Attention! Smile [:)]

Do you create a new document using Aspose.Words or loading an existing one?

Please send us exact code line that you are using, together with the document that you are trying to load.

Well, I'm creating a new document using Aspose.Words. My source code is based on Delphi 7 (I'm using the ManagedVCL to make the code conection with .Net FrameWork)

Here is my code:


type
v = Variant;

function x(const Params: array of v): v;
begin
Result := VarArrayOf(Params);
end;

procedure MakeAsposeDocument;
var
AsposeWordAssembly,
strLicense: String;
begin
// Aspose Library
if FileExists('C:\Program Files\Aspose\Aspose.Words\Bin\Aspose.Words.dll') then
AsposeWordAssembly := 'C:\Program Files\Aspose\Aspose.Words\Bin\Aspose.Words.dll'
else
raise Exception.Create('Error Aspose Library');

// Aspose License
if FileExists('C:\Program Files\Aspose\Aspose.Words\License\Aspose.Word.lic') then
try
strLicense := 'C:\Program Files\Aspose\Aspose.Words\License\Aspose.Word.lic'
license := ClrCreateInstanceFrom(AsposeWordAssembly, 'Aspose.Words.License');
license.SetLicense(strLicense);
except
raise Exception.Create('Error Aspose License');
end;
end;

// Temporary file
arq := 'C:\MyDoc' + '.doc';

// Creating the document
try
doc := ClrCreateInstanceFrom(AsposeWordAssembly, 'Aspose.Words.Document', x([Variant(arq)]));
except
raise Exception.Create('Error creating document: ' + Exception(ExceptObject).Message);
end;

// Creating the document builder
try
builder := ClrCreateInstanceFrom(AsposeWordAssembly, 'Aspose.Words.DocumentBuilder', x([doc]));
except
raise Exception.Create('Error creating document builder: ' + Exception(ExceptObject).Message);
end;

// Other Aspose.Word functions...

end;

I don't have Delphi7 to test but I beleive you are using wrong CreateInstanceFrom overload to pass parameters. Here is the list of overloads as they appear in MSDN:

Overload List:

Creates an instance of the type whose name is specified, using the named assembly file and default constructor.

[C#] public static ObjectHandle CreateInstanceFrom(string, string);

Creates an instance of the type whose name is specified, using the named assembly file and default constructor.

[C#] public static ObjectHandle CreateInstanceFrom(string, string, object[]);

Creates an instance of the type whose name is specified, using the named assembly file and the constructor that best matches the specified parameters.

[C#] public static ObjectHandle CreateInstanceFrom(string, string, bool, BindingFlags, Binder, object[], CultureInfo, object[], Evidence);

I think you should use the last overload. Here is how the call looks like in C#:

string assemblyName = @"C:\Program Files\Aspose\Aspose.Words\\bin\Aspose.Words.dll";

string typeName = "Aspose.Words.Document";

string filename = Application.StartupPath + @"\Doc1.doc";

ObjectHandle handle = Activator.CreateInstanceFrom(assemblyName, typeName, false, 0, null, new object[] {filename}, null, null, null);

Object obj = handle.Unwrap();

Dear Vladimir,

When I was with the Aspose.Word version, my source code generated the document perfectly. Now, with the Aspose.Words 3.5 version, my source code (the code that I've sent you) has no more the same function.

Could you send me your MSN contact please? We can talk more about it...

Bye!

Hi,

Assuming you are creating the document from scratch, this issue looks very strange because "Unknown file format" is normally thrown when an attempt of opening an unrecognized document format is made. Could you please explain what that temporary 'C:\MyDoc.doc' is for in your code?