Unable to set license of GroupDocs.Search

Hello I am using GroupDocs.Total.lic in my application and currently using the below

using (Stream stream = appAssembly.GetManifestResourceStream(resourceName))
{
    GD.Utilities.ApplyLicenseViewer(stream);
}

using (Stream stream = appAssembly.GetManifestResourceStream(resourceName))
{
    GD.Utilities.ApplyLicenseConversion(stream);
}

using (Stream stream = appAssembly.GetManifestResourceStream(resourceName))
{
    GD.Utilities.ApplyLicenseAnnotation(stream);
}

using (Stream stream = appAssembly.GetManifestResourceStream(resourceName))
{
    GD.Utilities.ApplyLicenseMerger(stream);
}

using (Stream stream = appAssembly.GetManifestResourceStream(resourceName))
{
    GD.Utilities.ApplyLicenseWatermark(stream);
}

Now I am planning to use Groupdocs.Search in my application and hence added the below code

using (Stream stream = appAssembly.GetManifestResourceStream(resourceName))
{
    GD.Utilities.ApplyLicenseSearch(stream);
}

but I am getting the error → License not Valid

groupdocs.search error.png (15.8 KB)

my full code is below

#region ProductLicense

/// <summary>
/// Set product's license 
/// </summary>
public static void ApplyLicense(string filepath)
{
    GroupDocs.Viewer.License lic1 = new GroupDocs.Viewer.License();
    lic1.SetLicense(filepath);
    //GroupDocs.Parser.License lic2 = new GroupDocs.Parser.License();
    //lic2.SetLicense(filepath);
}

/// <summary>
/// Set product's license for Viewer
/// </summary>
public static void ApplyLicenseViewer(Stream stream)
{
    GroupDocs.Viewer.License lic = new GroupDocs.Viewer.License();
    lic.SetLicense(stream);
}
/// <summary>
/// Set product's license for Parser
/// </summary>
public static void ApplyLicenseParser(Stream stream)
{
    GroupDocs.Parser.License lic = new GroupDocs.Parser.License();
    lic.SetLicense(stream);
}

/// <summary>
/// Set product's license for ApplyLicenseWatermark
/// </summary>
public static void ApplyLicenseWatermark(Stream stream)
{
    GroupDocs.Watermark.License lic = new GroupDocs.Watermark.License();
    lic.SetLicense(stream);
}
/// <summary>
/// Set product's license for Conversion
/// </summary>
public static void ApplyLicenseConversion(Stream stream)
{
    GroupDocs.Conversion.License lic = new GroupDocs.Conversion.License();
    lic.SetLicense(stream);
}
/// <summary>
/// Set product's license for Annotation
/// </summary>
public static void ApplyLicenseAnnotation(Stream stream)
{
    GroupDocs.Annotation.License lic = new GroupDocs.Annotation.License();
    lic.SetLicense(stream);
}
/// <summary>
/// Set product's license for Annotation
/// </summary>
public static void ApplyLicenseMerger(Stream stream)
{
    GroupDocs.Merger.License lic = new GroupDocs.Merger.License();
    lic.SetLicense(stream);
}

/// <summary>
/// Set product's license for Annotation
/// </summary>
public static void ApplyLicenseSearch(Stream stream)
{
    GroupDocs.Search.License lic = new GroupDocs.Search.License();
    lic.SetLicense(stream);
}
#endregion

below →

string viewerAssemblyName = "GroupDocs.Viewer.dll";
string signatureAssemblyName = "GroupDocs.Signature.dll";
string annotationAssemblyName = "GroupDocs.Annotation.dll";
string comparisonAssemblyName = "GroupDocs.Comparison.dll";
string conversionAssemblyName = "GroupDocs.Conversion.dll";
string searchAssemblyName = "GroupDocs.Search.dll";

// set GroupDocs.Viewer license
DomainGenerator viewerDomainGenerator = new DomainGenerator(viewerAssemblyName, "GroupDocs.Viewer.License");
viewerDomainGenerator.SetViewerLicense();

// set GroupDocs.Annotation license
DomainGenerator annotationDomainGenerator = new DomainGenerator(annotationAssemblyName, "GroupDocs.Annotation.License");
annotationDomainGenerator.SetAnnotationLicense();

// set GroupDocs.Conversion license
DomainGenerator conversionDomainGenerator = new DomainGenerator(conversionAssemblyName, "GroupDocs.Conversion.License");
conversionDomainGenerator.SetConversionLicense();

// set GroupDocs.Comparison license
DomainGenerator comparisonDomainGenerator = new DomainGenerator(comparisonAssemblyName, "GroupDocs.Comparison.Common.License.License");
comparisonDomainGenerator.SetComparisonLicense();

// set GroupDocs.Signature license
DomainGenerator signatureDomainGenerator = new DomainGenerator(signatureAssemblyName, "GroupDocs.Signature.License");
signatureDomainGenerator.SetSignatureLicense();

// set GroupDocs.Search license
DomainGenerator searchDomainGenerator = new DomainGenerator(searchAssemblyName, "GroupDocs.Search.License");
searchDomainGenerator.SetSearchLicense();

public class DomainGenerator
{
    private readonly Type CurrentType;

    /// <summary>
    /// Constructor
    /// </summary>
    public DomainGenerator(string assemblyName, string className)
    {
        // Get assembly path 
        string assemblyPath = GetAssemblyPath(assemblyName);
        // Initiate GroupDocs license class
        CurrentType = CreateDomain(assemblyName + "Domain", assemblyPath, className);
    }

    /// <summary>
    /// Get assembly full path by its name
    /// </summary>
    /// <param name="assemblyName">string</param>
    /// <returns></returns>
    private string GetAssemblyPath(string assemblyName)
    {
        // Get path of the executable
        string codeBase = Assembly.GetExecutingAssembly().CodeBase;
        UriBuilder uri = new UriBuilder(codeBase);
        string uriPath = Uri.UnescapeDataString(uri.Path);
        // Get path of the assembly
        string path = Path.Combine(Path.GetDirectoryName(uriPath), assemblyName);
        return path;
    }

    /// <summary>
    /// Create AppDomain for the assembly
    /// </summary>
    /// <param name="domainName">string</param>
    /// <param name="assemblyPath">string</param>
    /// <param name="className">string</param>
    /// <returns></returns>
    private Type CreateDomain(string domainName, string assemblyPath, string className)
    {
        // Create domain
        AppDomain dom = AppDomain.CreateDomain(domainName);
        AssemblyName assemblyName = new AssemblyName { CodeBase = assemblyPath };
        // Load assembly into the domain
        Assembly assembly = dom.Load(assemblyName);
        // Initiate class from the loaded assembly
        Type type = assembly.GetType(className);
        return type;
    }

    /// <summary>
    /// Set GroupDocs.Viewer license
    /// </summary>
    /// <param name="type">Type</param>
    public void SetViewerLicense()
    {
        SetLicense((GroupDocs.Viewer.License)Activator.CreateInstance(CurrentType));
    }

    /// <summary>
    /// Set GroupDocs.Annotation license
    /// </summary>
    /// <param name="type">Type</param>
    public void SetAnnotationLicense()
    {
        SetLicense((GroupDocs.Annotation.License)Activator.CreateInstance(CurrentType));
    }

    /// <summary>
    /// Set GroupDocs.Comparison license
    /// </summary>
    /// <param name="type">Type</param>
    public void SetComparisonLicense()
    {
        SetLicense((GroupDocs.Comparison.License)Activator.CreateInstance(CurrentType));
    }

    /// <summary>
    /// Set GroupDocs.Conversion license
    /// </summary>
    /// <param name="type">Type</param>
    public void SetConversionLicense()
    {
        SetLicense((GroupDocs.Conversion.License)Activator.CreateInstance(CurrentType));
    }

    /// <summary>
    /// Set GroupDocs.Signature license
    /// </summary>
    /// <param name="type">Type</param>
    public void SetSignatureLicense()
    {
        SetLicense((GroupDocs.Signature.License)Activator.CreateInstance(CurrentType));
    }

    /// <summary>
    /// Set GroupDocs.Search license
    /// </summary>
    /// <param name="type">Type</param>
    public void SetSearchLicense()
    {
        SetLicense((GroupDocs.Search.License)Activator.CreateInstance(CurrentType));
    }

    private void SetLicense(dynamic obj)
    {
        Assembly appAssembly = Assembly.GetExecutingAssembly();
        using (Stream stream = appAssembly.GetManifestResourceStream("DocPro.DMS.WebApp.GroupDocs.Total.lic"))
        {
            obj.SetLicense(stream);
        }
    }
}

I don’t know What I am doing wrong here

@Niteen_Jadhav

Could you please share the license file (please compress it to a ZIP format and share in private message).

shared the license file

@Niteen_Jadhav
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): TOTALNET-83

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@Niteen_Jadhav

May you please clarify if you use separate dlls or Nuget packages for each Groupdocs product - GroupDocs.Viewer, GroupDocs.Signature, etc. If yes - what are the versions of each used product?

Please note that it’s recommended to use a single GroupDocs.Total package from Nuget which provides better compatibility between GroupDocs products.

There are two options available dependent of target framework of your project:

May you please clarify if you use separate dlls or Nuget packages for each Groupdocs product - GroupDocs.Viewer, GroupDocs.Signature, etc

Yes I am using all the dlls Separtley

I am still getting same error.

Can you please brief me about this.

should I remove all the packages and then add Groupdocs.total?

and what should I change in my current code?

@Niteen_Jadhav

Yes I am using all the dlls Separtley

Thank you for confirming. In order to assist you effectively, could you kindly provide the versions of the DLLs you are currently using? This information will allow us to accurately replicate the behavior you’ve described on our end.

should I remove all the packages and then add Groupdocs.total?  
and what should I change in my current code?

Regarding your inquiry about switching to a single GroupDocs.Total package, we will guide you through the necessary steps and provide assistance with updating your code. We’ll keep you informed of our progress.

@Niteen_Jadhav

Please check attached TOTALNET-83.zip (6.8 KB) that demonstrates how to apply license for multiple GroupDocs products when use single GroupDocs.Total package.

Please let us know if it works for you.

Following Packages are automatically installed after installing GroupDocs.Total:
Aspose.Email 20.8
Aspose.PDF 19.9.0.0
Aspose.Words 20.1.0.0
GroupDocs.Assembly 20.6
GroupDocs.Classification 20.6.0.0
GroupDocs.Editor 20.7.0.0
GroupDocs.Metadata 20.8
GroupDocs.Redaction: 20.7

Following Packages are installed by me:
GroupDocs.Annotation: 20.8
GroupDocs.Comparison: 20.8
GroupDocs.Conversion: 20.8
GroupDocs.Merger: 20.8
GroupDocs.Parser: 20.8
GroupDocs.Search: 20.8
GroupDocs.Signature: 20.8
GroupDocs.Viewer: 20.8
GroupDocs.Watermark: 20.7

I Tried doing the following

var licPath = "Path";

Console.WriteLine("Setting license for GroupDocs.Viewer");
GroupDocs.Viewer.License viewerLicense = new GroupDocs.Viewer.License();
viewerLicense.SetLicense(licPath);

Console.WriteLine("Setting license for GroupDocs.Annotation");
GroupDocs.Annotation.License annotationLicense = new GroupDocs.Annotation.License();
annotationLicense.SetLicense(licPath);

Console.WriteLine("Setting license for GroupDocs.Conversion");
GroupDocs.Conversion.License conversionLicense = new GroupDocs.Conversion.License();
conversionLicense.SetLicense(licPath);

Console.WriteLine("Setting license for GroupDocs.Comparison");
GroupDocs.Comparison.License comparisonLicense = new GroupDocs.Comparison.License();
comparisonLicense.SetLicense(licPath);

Console.WriteLine("Setting license for GroupDocs.Signature");
GroupDocs.Signature.License signatureLicense = new GroupDocs.Signature.License();
signatureLicense.SetLicense(licPath);

Console.WriteLine("Setting license for GroupDocs.Search");
GroupDocs.Search.License searchLicense = new GroupDocs.Search.License();
searchLicense.SetLicense(licPath);

but on the following line → searchLicense.SetLicense(licPath); I am still getting the error that

license is not valid

image.png (107.5 KB)

@Niteen_Jadhav

Unfortunately I was unable to replicate the issue at our side. Could you provide a sample project that demonstrates problematic behavior?

Thanks.

this is 1 dev license and I cannot create another project with this license

@Niteen_Jadhav

this is 1 dev license and I cannot create another project with this license

Please refer to License Types - Purchase - groupdocs.com

"A Developer OEM License allows One developer to create an unlimited number of end user software using the product which can be used at an unlimited number of physical locations (distinct address or office building) within or outside of your organization. "

But if I create another application with this license I always get the error

@Niteen_Jadhav

We are investigating this scenario.

@Niteen_Jadhav

Could you please share such an application that demonstrates mentioned issue?

Sorry, it was a misunderstanding,

Actually The license was created for our server and hence, I was not able to create any application on my machine.

Now I created a sample application on server and added these licenses (added GroupDocs.Viewer License on server and remaining on my machine)

App Link

I am not facing any issues in this application.

So, Why I am facing the issue on my other application?

@Niteen_Jadhav

Thank you for provided application, we are investigating it and will return back when there are some updates.

Hello do we have any updates?

@Niteen_Jadhav

The issue is under investigation, as soon as we have any updates I’ll let you know.