0

I have a console application that references third party libraries whose source code I don't have:

1) Common.Logging.NLog, 2) Common.Logging, 3) NLog

After switching the Security option to "This is a partial trust application" (deployed in a network share drive), VS gave 4 warnings:

Warning 1   Reference 'Common.Logging.NLog' does not allow partially trusted callers.
Warning 2   Reference 'Common.Logging' does not allow partially trusted callers.
Warning 3   Reference 'NLog' does not allow partially trusted callers.
Warning 4   Use of app.config binding redirects requires full trust.

I tried the solution in C# - .NET 4.0 - That Assembly does not allow partially trusted callers by 1) Create a key using SN.EXE 2) Sign all my assemblies with this key.

After that the compiler complained that the third party libraries don't have a strong name.

Would anyone suggest a solution? I don't have direct control on the client machine, so I'd prefer a solution that doesn't require client machine configuration (for example, CASPOL.EXE).

UPDATE_1

I added <NetFx40_LegacySecurityPolicy enabled="true" /> to app.config. It went passed the first SecurityException, but died at a later point for the same error.

Thanks.

Community
  • 1
  • 1
Candy Chiu
  • 6,579
  • 9
  • 48
  • 69

2 Answers2

1

After some trial and error, I found a way to get the sample app working.

  1. Download the code.
  2. Set the Target Framework of each project to .NET 4.
  3. Sign each project with the same key. (I didn't experiment signing them with different keys)
  4. Compile everything.
  5. Add to App.config

       <runtime>             
         <NetFx40_LegacySecurityPolicy enabled="true" />
       </runtime> 
    
Candy Chiu
  • 6,579
  • 9
  • 48
  • 69
0

You may be in luck -- all three assemblies are open source and live on github, so you can compile them yourself and sign with your choice of strong-name key. Links to the project source repository pages are:

Jeffrey Hantin
  • 35,734
  • 7
  • 75
  • 94
  • The target framework version of these libraries are .NET 2.0. Do I need to change it to .NET 4? Thx! – Candy Chiu Mar 20 '12 at 13:18
  • I tried to compile all third party dependencies. Unfortunately one of the libraries modify the source of its dependency. I can't get to the modified source. I guess I have reached the deadend. – Candy Chiu Mar 20 '12 at 14:07
  • I created a test project that compiles only Common.Logging, NLog, and a EXE project that logs a message. The target framework of Common.Logging is 2.0, and NLog's is 4. I signed all projects with one key. Added to App.config. The program still throws "That assembly does not allow partially trusted callers." – Candy Chiu Mar 21 '12 at 16:07