Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ASP.NET medium trust

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support
View previous topic :: View next topic  
Author Message
James
Guest





PostPosted: Thu Feb 23, 2006 2:41 am    Post subject: ASP.NET medium trust Reply with quote

I recently purchased your licensing component to use with an ASP.NET control, however when I validate a license when testing under medium trust it throws an exception.
Quote:
Attempt to access the method failed.
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.MethodAccessException: Attempt to access the method failed.

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:


[MethodAccessException: Attempt to access the method failed.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +103
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +261
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1036
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +114
System.Activator.CreateInstance(Type type, Object[] args) +16
System.SecurityUtils.SecureCreateInstance(Type type, Object[] args) +106
System.ComponentModel.LicenseManager.ValidateInternalRecursive(LicenseContext context, Type type, Object instance, Boolean allowExceptions, License& license, String& licenseKey) +178
System.ComponentModel.LicenseManager.ValidateInternal(Type type, Object instance, Boolean allowExceptions, License& license) +41
System.ComponentModel.LicenseManager.IsValid(Type type, Object instance, License& license) +10

How do I fix this?
Back to top
James
Guest





PostPosted: Thu Feb 23, 2006 3:19 am    Post subject: Reply with quote

Never mind, I fixed it myself. I replaced the call to LicenseManager.IsValid with a call to a new method:
Code:
      public virtual EncryptedLicense GetLicense(string licenseParameters, Type type)
      {
         SetParameters(licenseParameters);
         return GetLicense(type);
      }

      public virtual EncryptedLicense GetLicense(Type type)
      {
         string licPath = GetLicenseFilePath(LicenseManager.CurrentContext, type);
         string licenseKey = ReadKeyFromFile(licPath);

         EncryptedLicense license = null;
         if (licenseKey != null)
         {
            license = LoadLicense(LicenseManager.CurrentContext, type, licenseKey);
         }
         return license;
      }

You need to pass in the type as Assembly.GetEntryAssembly() returns null in ASP.NET.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group