1
can i implement gleamtech DocumentUltimate in sharepoint asp.net
Question asked by Shyam Raghuvanshi - 8/1/2019 at 2:02 AM
Answered
 i want implement gleamtech DocumentUltimate in sharepoint asp.net but facing issue could not load assembly.

12 Replies

Reply to Thread
0
Cem Alacayir Replied
Employee Post
Yes, Sharepoint is supported. See my reply here:
0
Shyam Raghuvanshi Replied
my could not load error is resolve but i got System.NullReferenceException: Object reference not set to an instance of an object 

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]   GleamTech.AspNet.UI.ComponentStateManager.SaveState(String stateId, ComponentState state) +66   GleamTech.AspNet.UI.ComponentRenderer.SaveState(StatefulComponent statefulComponent, String requestPath) +238   System.Web.UI.Control.PreRenderRecursiveInternal() +161   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6874
0
Cem Alacayir Replied
Employee Post Marked As Answer
It seems PreApplicationStartMethodAttribute is not triggered on Sharepoint and as a result HttpContext comes as null thus the NullReferenceException.
Reference: 

As a workaround, call this method in the Application_Start method of your Global.asax.cs:

protected void Application_Start(object sender, EventArgs e)
{
    GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart();    
}
0
Shyam Raghuvanshi Replied
i have no any Global.asax.cs file in sharepoint so where i implement it.can you please give me any solution of it.
because without it i got following error

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]   GleamTech.AspNet.UI.ComponentStateManager.SaveState(String stateId, ComponentState state) +66   GleamTech.AspNet.UI.ComponentRenderer.SaveState(StatefulComponent statefulComponent, String requestPath) +238   System.Web.UI.Control.PreRenderRecursiveInternal() +161   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Control.PreRenderRecursiveInternal() +255   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6874

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3282.0 
0
Cem Alacayir Replied
Employee Post
Why are you reposting the same error message? I already gave you a solution, don't you know how to search specifics about Sharepoint?

The idea is to call this somewhere once application starts, it doesn't necessarily has to be Global.asax (if it's hard to implement in Sharepoint):

GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart();
References:

0
Shyam Raghuvanshi Replied
I create a Handler And also create override Global Asax File as you gave us a solution but in both case i got following error

Cannot register a module after the application has been initialized.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Cannot register a module after the application has been initialized.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: 

[InvalidOperationException: Cannot register a module after the application has been initialized.]   System.Web.DynamicModuleRegistry.Add(Type moduleType) +244   System.Web.HttpApplication.RegisterModule(Type moduleType) +75   GleamTech.AspNet.NetFramework.WebActivation.PreApplicationStart() +404   GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart() +52   GleanTechModule.Application_BeginRequest(Object source, EventArgs e) +42   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +139   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +88
 

0
Shyam Raghuvanshi Replied
I waiting of your reply.
0
Cem Alacayir Replied
Employee Post
HttpHandler is too late for this purpose (thus the exception), you should create a simple HttpModule, see this reply here: https://stackoverflow.com/a/6451286

The global.asax doesn't seem to be the best solution to do this because of the deployment issues described in the question.
A viable solution is implementing this in a httpmodule
The init method can be used to wire everything up since this is called when the sharepoint application starts.
the httpmodule can be added in the web.config by a feature receiver
This way there is no need to do tricks with the global.asax that is located in a directory you can't deploy to with a feature and you have all the functionality and correct time to instantiate the DI container.

I prepared you some code which implements the idea of the above StackOverflow reply. I don't have Sharepoint currently to test but it should work. Let me know.

GlobalHttpModule.cs:
using System.Web;

public class GlobalHttpModule : IHttpModule
{
    public void Init(HttpApplication app)
    {
        //The init method can be used to wire everything up since this is called when the Sharepoint application starts.

        GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart();
    }

    public void Dispose()
    {
    }
}

GlobalHttpModuleFeature.cs
public class GlobalHttpModuleFeature : SPFeatureReceiver
{
    private readonly Type targetHttpModuleType = typeof(GlobalHttpModule);

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        var webApp = properties.Feature.Parent as SPWebApplication;

        var modification = GetModification();

        webApp.WebConfigModifications.Add(modification);
        webApp.Update();

        webApp.WebService.ApplyWebConfigModifications();
    }

    public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
        var webApp = properties.Feature.Parent as SPWebApplication;

        var modification = GetModification();

        webApp.WebConfigModifications.Remove(modification);
        webApp.Update();

        webApp.WebService.ApplyWebConfigModifications();
    }

    private SPWebConfigModification GetModification()
    {
        var modification = new SPWebConfigModification(
            string.Format("add[@name='{0}']", targetHttpModuleType.Name), 
            "configuration/system.webServer/modules"
        );
        modification.Sequence = 0;
        modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
        modification.Value = string.Format(
            @"<add name=""{0}"" type=""{1}"" />",
            targetHttpModuleType.Name,
            targetHttpModuleType.AssemblyQualifiedName);
    }
}

References:

0
Shyam Raghuvanshi Replied
Hello sir,
I have implement httpmodule as you suggest and also add a feature but got same error


Cannot register a module after the application has been initialized.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Cannot register a module after the application has been initialized.
Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: 
[InvalidOperationException: Cannot register a module after the application has been initialized.]   System.Web.DynamicModuleRegistry.Add(Type moduleType) +244   System.Web.HttpApplication.RegisterModule(Type moduleType) +75   GleamTech.AspNet.NetFramework.WebActivation.PreApplicationStart() +404   GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart() +52   GleanTechModule.Application_BeginRequest(Object source, EventArgs e) +42   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +139   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +88
 



0
Shyam Raghuvanshi Replied
I am waiting of your response please give me a alternate solution of it.
0
Cem Alacayir Replied
Employee Post
You will only use GlobalHttpModule.cs and GlobalHttpModuleFeature.cs and not any code or modification from above replies (remove older ones). 

According to the error message:

GleamTech.DocumentUltimate.AspNet.NetFramework.WebActivation.PreApplicationStart() +52   GleanTechModule.Application_BeginRequest(Object source, EventArgs e) +42 
It seems you are still calling PreApplicationStart when request starts (Application_BeginRequest)
0
Shyam Raghuvanshi Replied
I have few question for DocumentUltimate.
1. can we configurable download option and some other option by code.
2. which kind of file format supports it.(like pdf,tif)

Reply to Thread