2

Im trying to make this plugin run in my ASP project. I´m familiar with C# but never tried an ASP.net project before.

I tried doing everthing exacly like in this blog here:

http://codeutil.wordpress.com/2013/09/16/convert-html-to-pdf/

But Im getting stuck with the following error message: " Constructor on type 'Pechkin.SimplePechkin' not found."

The happens when I call the method to get a instance of the Pechkin : ( This one below)

var pechkin = Factory.Create(new GlobalConfig());

When I debug(F11) that line of code I step into the Pechkin code and the line that returns the error is:

ObjectHandle handle = Activator.CreateInstanceFrom(
        Factory.operatingDomain,
        location,
        typeof(SimplePechkin).FullName,
        false,
        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
        null,
        new object[] { config },
        null,
        null,
        null);

Taking a look at the SimplePechkin.cs it has a constructor :

/// <summary>
/// Constructs HTML to PDF converter instance from <code>GlobalConfig</code>.
/// </summary>
/// <param name="config">global configuration object</param>
public SimplePechkin(GlobalConfig config)
{
    this._onErrorDelegate = new StringCallback(this.OnError);
    this._onFinishedDelegate = new IntCallback(this.OnFinished);
    this._onPhaseChangedDelegate = new VoidCallback(this.OnPhaseChanged);
    this._onProgressChangedDelegate = new IntCallback(this.OnProgressChanged);
    this._onWarningDelegate = new StringCallback(this.OnWarning);

    Tracer.Trace("T:" + Thread.CurrentThread.Name + " Creating SimplePechkin");

    this._globalConfig = config;

    Tracer.Trace("T:" + Thread.CurrentThread.Name + " Created global config");

    this.IsDisposed = false;
}

I think that error should not be going on, specially because if I run it on a common C# winforms test project it works ok. Maybe is because I´m a noob with ASP.net.

Can you guys please help?

Here is the link to the github Pechkin repository if someone wants to give it a try.

https://github.com/tuespetre/Pechkin

Thank you for reading!

-Roiw

Roiw
  • 147
  • 2
  • 16
  • Roiw, I'm sorry I might be too late (over a month!) But did you happen to find a solution? If you look at the code that returns the error, you can see that it's specifying the NonPublic binding flag. I think this means that the library requires Full Trust to run. – tuespetre Apr 08 '14 at 14:25
  • Thank you for replying @tuespetre, I had abbandoned the project since I couldn't find a solution. But since you suggested sommething I decided to reopen it and try it out. But it did not work. Do you know how to run a library in full trust? I tried : `` But I Dont have a public key because Pechkin is not a strongly named assembly. So If you know how to do that I'm interested in learning. :-) – Roiw Apr 08 '14 at 17:38
  • I'm not too experienced with anything besides Full-trust myself, but here is a good article explaining it (from MDSN): http://msdn.microsoft.com/en-us/library/wyts434y.ASPX Being in some lower trust is the only reason I can think of that you wouldn't have access to the constructor... Love a puzzle! – tuespetre Apr 08 '14 at 18:45

0 Answers0