COM Interopt and _License

I have a working application using C++ and the COM Interop for Aspose.Words. I recently received our license.

I am having trouble with CoCreateInstance. I am trying to get the license Interface so I can call SetLicense. CoCreateInstance keeps failing with REGDB_E_CLASSNOTREG.

CComPtr<_License> piLic;
hr = CoCreateInstance(CLSID_License,  NULL,
  CLSCTX_LOCAL_SERVER,
  IID__License,
  (void**) &piLic );

Bill

Hi

Thanks for your request. Does the problem occur only with License object? Can you create instances of other classes, Aspose.Words.Document for example?

Also, could you please describe your environment and specify what IDE you use?

Best regards,

CComPtr<_Document> piDoc = NULL;
CComPtr<_ComHelper> piHelper;
hr = piHelper.CoCreateInstance(CLSID_ComHelper);
CComBSTR bsSrcFilename = lpsSrcFilename;
hr = piHelper->Open(bsSrcFilename, &piDoc);


I am using Visual studio 2010 to create a C++ project, the above successfully opens a document.

I include ASpose.Words.tlb using the following

#import "Aspose.words.tlb" named_guids raw_interfaces_only

I used RegAsm to register the assembly

C:\Program Files\Aspose>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe aspose.words.dll /codebase

The dll I am using is the following
C:\Program Files\Aspose\Aspose.Words for .NET\bin\net2.0\Aspose.Words.dll

I am also working with Aspose.Cells and I am getting a slightly different behavior.


CComPtr<_License> piLic;
hr = piLic.CoCreateInstance(CLSID_License);
hr = piLic->SetLicense(_T(“c:\Aspose.Total.lic”));
CComPtr<_Workbook> piBook;
hr = piBook.CoCreateInstance(CLSID_Workbook);
hr = piBook->Open_5(bsSrcFilename);
hr = piBook->Save_5(bsDstFilename, FileFormatType_Pdf);

In the above code; CoCreateInstance and SetLicense succeed and return hr = 0.

But the PDF workbook created still has the “Evaluation Only” stamped on the output.

Hello,

Thank you for additional information.
Could you please check if you have the registry key HKEY_CLASSES_ROOT\Aspose.Words.License\CLSID. Take the value of this key (GUID, in my case it {EFA643A2-F23B-30D0-AE15-B84FC7120F03}, in your case it will be different). And seek another branch in the registry HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{EFA643A2-F23B-30D0-AE15-B84FC7120F03}\InprocServer32.
there should be information about the latest version of the library 9.7.0.0.

If these keys do not exist try to re-register the library.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe /unregister aspose.words.dll
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe aspose.words.dll /codebase

I do not have this registry entry


HKEY_CLASSES_ROOT\Wow6432Node\CLSID{EFA643A2-F23B-30D0-AE15-B84FC7120F03}\InprocServer32.

I do not have this node at all

\Wow6432Node

Every time I UNregister/register the words dll the following key gets added/deleted

HKEY_CLASSES_ROOT\CLSID{EFA643A2-F23B-30D0-AE15-B84FC7120F03}\InprocServer32.

Aspose.Words, Version=9.7.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56

the version seams to be correct I just downloaded the latest DLL only distribution.

I created new TLBs from the new dlls.

I still get class not registered for Aspose.words.License


void CasposeDlg::OnBnClickedOk()
{
HRESULT hr = S_OK;
using namespace Aspose_Words;

CComPtr<_License> piLic;
hr = CoCreateInstance(CLSID_License, NULL, CLSCTX_INPROC_SERVER, IID__License, (void **)&piLic);

BSTR bsLic = _T("c:\\ASpse.Total.lic");
hr = piLic->SetLicense(bsLic);

CComPtr<_Document> piDoc = NULL;

CComPtr<_ComHelper> piHelper;
hr = piHelper.CoCreateInstance(CLSID_ComHelper);

CComBSTR bsSrcFilename = _T("Z:\\test_files\\ASpose\\inputs\\Doc\\3PageResume.doc");

hr = piHelper->Open(bsSrcFilename, &piDoc);

CComBSTR bsDstFilename = _T("c:\\a.pdf");

hr = piDoc->Save_2(bsDstFilename, SaveFormat_Pdf, NULL);

return;
}

This piece of code creates the pdf output file but the "DEMO ONLY" content is added to the document.

the SetLicense returns S_OK but the license file name is incorrect.

Hi Bill,

Thank you for additional information. I successfully create an instance of License on my side using code like the following:

CComPtr<_License> piLic;
hr = piLic.CoCreateInstance(CLSID_License);

Also, since you have problems with other Aspose products too, I will move this thread to Aspose.Total forum for further discussion. So my colleagues from other team also will participate.

Best regards,

Alexey,

after registering the newer version of aspose.Word and changing the cocreateInstance to agree with your suggestion.

now cocreateInstance succeeds but SetLicense dose not seam to work? Regardless of the path to the license files ( in this case it is invalid) SetLicense returns sucess and the converted doc->pdf has the "Evaluation Only" stamped on the top of the output file?

CComPtr<_License> piLic;

hr = piLic.CoCreateInstance(CLSID_License);

BSTR bsLic = _T("c:\\ASpse.Total.lic");
hr = piLic->SetLicense(bsLic);

thanks,
Bill

Hi

Thank you for the additional information. I think, as a simplest solution, you can create a simple wrapper, which will allow setting the license and do other things you need to do with documents. In this case, you will write all the code in a .NET class library and call only one method of this library from your COM application.

Hope this helps.

Best regards.