SLP Code Protector Discussion For conversations regarding usage of Code Protector and issues pertaining to SVM protected code.
InishTech Support Forums > SLP Code Protector Discussion > Failure to Load Permutation Assembly Login to add this as a favourite.
User avatar
Member
Member
nheembrock - 5/10/2011 9:43:43 PM
   
Failure to Load Permutation Assembly

Hello,

I've recently come across an issue when using a new Permutation. (This is going from V2.0 to V3.1). My assembly gets protected just fine. I can use Reflector and see that it actually is protected. However,when this assembly is deployed on a test server, it throws the following error when a protected method is invoked: 

 

 

Microsoft1Licensing1Runtime210N: Failed to load permutation assembly for runtime v2.0.50727; Short Code: b0eb8 Assembly Name: Microsoft.Licensing.Permutation2.0, Version=3.1.1915.38, Culture=neutral, PublicKeyToken=5b7832056d5afd0b; Location: (none loaded) ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\assembly\GAC_MSIL\KnowledgeLake.Capture.Server.Common\4.0.0.0__b88de33648dde56f\Microsoft.Licensing.Permutation2.0.dll' or one of its dependencies. The system cannot find the file specified.

File name: 'file:///C:\Windows\assembly\GAC_MSIL\KnowledgeLake.Capture.Server.Common\4.0.0.0__b88de33648dde56f\Microsoft.Licensing.Permutation2.0.dll'

   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)

   at Microsoft1Licensing1Runtime210C.C(String A_0)

   at Microsoft1Licensing1Runtime210C.C()

 

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll

Running under executable  C:\Program Files\KnowledgeLake\Capture Server\KLCSConfig.exe

--- A detailed error log follows. 

 

=== Pre-bind state information ===

LOG: User = NICKCS\Administrator

LOG: Where-ref bind. Location = C:\Windows\assembly\GAC_MSIL\KnowledgeLake.Capture.Server.Common\4.0.0.0__b88de33648dde56f\Microsoft.Licensing.Permutation2.0.dll

LOG: Appbase = file:///C:/Program Files/KnowledgeLake/Capture Server/

LOG: Initial PrivatePath = NULL

Calling assembly : (Unknown).

===

LOG: This bind starts in LoadFrom load context.

WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().

LOG: Using application configuration file: C:\Program Files\KnowledgeLake\Capture Server\KLCSConfig.exe.Config

LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.

LOG: Attempting download of new URL file:///C:/Windows/assembly/GAC_MSIL/KnowledgeLake.Capture.Server.Common/4.0.0.0__b88de33648dde56f/Microsoft.Licensing.Permutation2.0.dll.

 

   --- End of inner exception stack trace ---

   at Microsoft1Licensing1Runtime210C.C()

   at Microsoft1Licensing1Runtime210C.E()

   at Microsoft1Licensing1Runtime210L.A()

   at Microsoft.Licensing.SLMRuntime.B()

   at Microsoft.Licensing.SLMRuntime.A()

   at Microsoft.Licensing.SLMRuntime.Slps.Distributor.Core.Contracts.DistributorHooks.IsProtected(Assembly assembly)

   at Microsoft.Licensing.SLMRuntimeFactory.CachedForProtectedAssembly(Assembly associatedAssembly)

   at Microsoft.Licensing.SLMRuntime.InternalSVMExecMethod(Assembly declaringAssembly, String SVMMethodId, ISLMVirtualMachineParams paramsReader)

   at Microsoft.Licensing.SLMRuntime.SVMExecMethod(Object obj, String SVMMethodId, Object[] args, Type[] genericTypeParams, Type[] genericMethodParams)

   at KnowledgeLake.Capture.Server.Common.Encryption.EncryptKey(String key)

   at KnowledgeLake.Capture.Server.ServicesConfiguration.Main.btnDBSave_Click(Object sender, EventArgs e)

   at System.Windows.Forms.Control.OnClick(EventArgs e)

   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.ButtonBase.WndProc(Message& m)

   at System.Windows.Forms.Button.WndProc(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

...

As you can see, it is attempting to load Microsoft.Licensing.Permutation2.0.dll instead of the new Permutation dll which includes the shortcode in it assembly name. The short code listed at the very beginning of the error message is also not the correct short code. Also, it is attempting to look in the same GAC folder that my protected assembly resides in. This behavior is exhibited even if I take the assemblies out of the GAC and attempt to load it from the program's install directory.

Any help at all woud be greatly appreciated and I can provide more information if needed.

Thanks!

Nick

 

 


User avatar
InishTech Dev
InishTech Dev
RBartelink - 5/11/2011 12:32:16 PM
   
RE:Failure to Load Permutation Assembly

 Hi Nick,

Havent seen any issue like this before so will start with a barrage of questions before attempting to suggest anything, much less resolve.

Can you confirm the contents of the directory containing your config app (C:\Program Files\KnowledgeLake\Capture Server\KLCSConfig.exe) folder please, (i.e., dir /b C:\Program Files\KnowledgeLake\Capture Server) - want to understand if your permutation DLL is present and correct. Does changing the current directory before running the app to that same directory too?

Am I correct in assuming that your protected assembly is KnowledgeLake.Capture.Server.Common  and that it is in the GAC? Does removing that assembly from the GAC cause things to work again? (I assume you have your module in the GAC for a reason, but I'd be interested to understand exactly why that is too)

--Ruben


User avatar
Member
Member
nheembrock - 5/12/2011 1:25:35 PM
   
RE:Failure to Load Permutation Assembly

 To answer your first question, in my program's install directory I have

  • a protected version of KnowledgeLake.Capture.Server.Common (the assembly I am having trouble with),
  • Microsoft.Licensing.Permutation_cc7ca_2.0.DLL
  • Microsoft.Licensing.Runtime2.0.DLL
  • Microsoft.Licensing.Utils2.0.DLL

All three of the Licensing dlls are the latest I have used to protect my assembly. 

I apologize, I am not sure what you mean with this question: Does changing the current directory before running the app to that same directory too?

You are correct in assuming that KnowledgelLake.Capture.Server.Common is my protected assembly. Unfortunately, removing it from the GAC does not resolve the issue. Instead, the error it spits out is that it is looking for the permutation file in my program's install directory rather than in the GAC folder. Even though I am encrypting the assembly using our latest permutation it seems like it is trying to load the old Microsoft.Licensing.Permutation dll.

Is there any other information I can provide to you?


User avatar
InishTech Dev
InishTech Dev
RBartelink - 5/12/2011 1:51:11 PM
   
RE:Failure to Load Permutation Assembly

 Hi Nick,

The search should include the application base directory. If I'm correct, that's wherever KLCSConfig.exe lives in your case.   If your protected assembly lives in the GAC and your permutation assembly does not, then there's no way for system to figure out where to get your DLL - it has to be the GAC or the application base directory.   In general, as part of diagnosing this sort of thing, the first step is to take everything out of the GAC and stick it in a single directory and then introduce the complexities of some assemblies living in different directories and/or the GAC one by one until you've isolated the obstacle.

So, to expand on the question you asked for clarification of... what app is executing the protected code?

Is it C:\Program Files\KnowledgeLake\Capture Server\KLCSConfig.exe ?

If so, does going to a command line and doing

    CD C:\Program Files\KnowledgeLake\Capture Server

    KLCSConfig.exe

change the outcome?    

User avatar
Member
Member
nheembrock - 5/12/2011 2:21:31 PM
   
RE:Failure to Load Permutation Assembly

I cleared the GAC of my protected assembly as well as of the three entries for the Microsoft.Licensing dlls. I then ran the command you specified but still receive the same error. The only difference is that now, instead of trying to load the Permutation dll from the GAC it is attempting to load it from my install directory. Do you know why it might be looking for the assembly "Microsoft.Licensing.Permutation2.0" rather than "Microsoft.Licensing.Permutation_cc7ca_2.0"?


User avatar
InishTech Dev
InishTech Dev
RBartelink - 5/12/2011 3:34:26 PM
   
RE:Failure to Load Permutation Assembly

Good question/probing.

While this issue has not been reported by other users, clearly there is an issue with how it's determining the DLL to use - typically it reads the short code from the header of the protected assembly and uses that to determine the appropriate permutation DLL to use. The API should be reporting an exception if it cannot determine the ID but seems to be failing to do so in your case.

A brute force way of making sure it does the right thing is to do:

 SLMRuntimeFactory.CachedFor( typeof(AClassInYourProtectedAssembly).Assembly, "abc12") // where abc12 is your short code

before running your protected code.

I've logged a bug regarding this which will be processed in due course to attempt a repro and fix if a repro can be found.

In the meantime, any assistance you can provide with isolating the cause would be appreciated.

You're running under CLR 4 (which is fully supported; we have many other customers using CLR 4), but for the purposes of isolating the issue, it may help to force CLR 2 to be used instead to see if the issue can be isolated this way.

Does putting a KLCSConfig.exe.config beside  KLCSConfig.exe that forces a 2.0 CLR (i.e. by using Microsoft.Licensing.CodeProtector.exe.config as a template) make the problem go away?

Can you confirm that KnowledgeLake.Capture.Server.Common

a) is protected 

b) contains a _SLM_HD.DAT resource (you can load the DLL into VS or use a tool like Reflector)

(Feel free to send a copy of the DLL to our support email and I'll look either)

EDIT: Another thing to try on a test box is to make  Microsoft.Licensing.Permutation2.0.dll available to your app, either in the GAC or on disk (the file is *not* redistributable though) and see if that makes it get any further.

--Ruben

 


User avatar
Member
Member
nheembrock - 5/12/2011 4:06:57 PM
   
RE:Failure to Load Permutation Assembly

 Where would I place that code for the brute force workaround?

I will try the 2.0 CLR experiment and get back to you ASAP.

Also, I can say that yes, KnowledgeLake.Capture.Server.Common is protected. Also, there is not an _SLM_HD.DAT file. There is, however, a _SVM_BUF.DAT. Is this expected behavior?

Thanks,

Nick


User avatar
InishTech Dev
InishTech Dev
RBartelink - 5/13/2011 12:53:23 PM
   
RE:Failure to Load Permutation Assembly

> Also, I can say that yes, KnowledgeLake.Capture.Server.Common is protected. Also, there is not an _SLM_HD.DAT file. There is, however, a _SVM_BUF.DAT. Is this expected behavior?

The _BUF is the protected code. The _HD is the header containing the product name and the permutation code for when you dont use the API. Perhaps the way its protected is causing the header to not be included.

This is the bit that seems to be going wrong.

May be worth doing a simple protect of something simple in isolation to confirm this fact as this is just off the top of my head.

--Ruben


User avatar
Member
Member
nheembrock - 5/12/2011 4:41:04 PM
   
RE:Failure to Load Permutation Assembly

 My application doesn't like to run on 2.0 CLR as it turns out. I would be really interested in trying the brute force method, I just need a little guidance on how to implement the code. 


User avatar
InishTech Dev
InishTech Dev
RBartelink - 5/13/2011 12:44:32 PM
   
RE:Failure to Load Permutation Assembly

nheembrock wrote: I would be really interested in trying the brute force method, I just need a little guidance on how to implement the code. 

Before any protected code executes, it means that even if the decision as to which DLL to use just in time based on the protected assembly header goes wrong, it'll already have the right one loaded  and use that instead

The code should just be:

SLMRuntimeFactory.CachedFor( typeof(AClassInYourProtectedAssembly).Assembly, "abc12") // where abc12 is your short code

 


1 2

There are currently no users on-line.

  • Sticky
  • Locked sticky
  • Hot sticky
  • Hot locked sticky
  • Thread
  • Hot thread
  • Locked thread