3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
956 stars 133 forks source link

Failed to define security permission set for 0x20000001 #19

Open OmegaExtern opened 7 years ago

OmegaExtern commented 7 years ago

Can't build the program any more, it fails because of this error:

...\packages\DllExport.1.5.0\tools\net.r_eg.DllExport.targets(42,5): error : error : Failed to define security permission set for 0x20000001

I'm running VS2015 with administrator privileges, and I've just upgraded DllExport to v1.5.

3F commented 7 years ago

nice

... with administrator privileges

only with ? and what IL Assembler from your settings ? anyway, can you check with both type ? Thanks,

OmegaExtern commented 7 years ago

only with ?

Well, this is new. Can you be more specific, what's your question?

what IL Assembler from your settings ?

I have used Direct-Mod... I don't have time for testing this now, I've expected v1.5 to work just right, and it just disappointed me.

3F commented 7 years ago

Can you be more specific,

This only when you build with administrator privileges ?

I have used Direct-Mod...

My question about IL Assembler ! 1.5+ now provides also my modified version of coreclr /ILAsm [?]

Look here: https://github.com/3F/DllExport/issues/17

    * NEW: Added our custom IL Assembler as option to fix incorrect 0x13 / 0x11 opcodes. #17
           GUI Configurator + MSBuild property: `DllExportOurILAsm`
           It should help for users of Fody projects, etc.
           https://github.com/Fody/Fody/issues/271

           IlAsm 4.5.1 https://github.com/3F/coreclr
           based on 4.5.22220.0 / coreclr 1.0.4
changelog of our coreclr for this release: https://github.com/3F/coreclr/blob/master/changelog.txt

ilasm

<DllExportOurILAsm>true</DllExportOurILAsm>

So, what coreclr version for this problem ?

3F commented 7 years ago

unfortunately I can't reproduce your problem on v1.5.0.33792 [ ab1c3e6 ] also with administrator privileges

I need details - how to reproduce your problem ?

You can also attach the build log and project file.

But first, use diagnostic verbosity:

For VS IDE:

For msbuild.exe:

bidolah commented 7 years ago

1) Advance Build Setting -> Output ->Debug info set to "none" 2) DllExportOurILAsm = false This steps fix this error. But I need debug my program

3F commented 7 years ago

@bidolah

I have this error when package "Costura.Fody" https://github.com/Fody/Costura installed. Advance Build Setting -> Output ->Debug info set to "none" DllExportOurILAsm = false This steps fix this error. But I need debug my program

Did I understand correctly that you have Failed to define security permission set for 0x20000001 when you are using Costura.Fody + DllExportOurILAsm = true ?

send me your build log with diagnostic verbosity ( if it's possible ). I will check the Costura.Fody later

see also bug for Fody/ModuleInit - issue #17

bidolah commented 7 years ago

@3F Yes,

Did I understand correctly that you have Failed to define security permission set for 0x20000001 when you are using Costura.Fody + DllExportOurILAsm = true ?

<Costura.Fody + DllExportOurILAsm = true> ==> Failed to define security permission set for 0x20000001

<Costura.Fody + DllExportOurILAsm = false> ==> error : Undeclared identifier IL_0098

Severity Code Description Project File Line Suppression State Error ~PRIVATE~\AppData\Local\Temp\tmp261F\~PRIVATE.il(2297) : error : Undeclared identifier IL_0098 ~PRIVATE\Application.cs(69) : error : syntax error at token ':' in: IL_0098: br.s IL_009a ~PRIVATE~ packages\DllExport.1.5.1\tools\net.r_eg.DllExport.targets 42

OR(when i delete part of AppDomain.AssemblyResolve Event)

Severity Code Description Project File Line Suppression State Error ~PRIVATE.il(11601) : error : Undeclared identifier IL_0186 ~PRIVATE\ServiceConfiguration.cs(130) : error : syntax error at token ':' in: IL_0186: br.s IL_0188 ~PRIVATE\packages\DllExport.1.5.1\tools\net.r_eg.DllExport.targets 42

Part of building log **<Costura.Fody + DllExportOurILAsm = true> ==> Failed to define security permission set for 0x20000001**

1> Deleting unused reference to DllExport. (TaskId:63) 1> Parsing 30839 lines of IL took 286 ms. (TaskId:63) 1> calling '"~PRIVATE~"\packages\DllExport.1.5.1\tools\coreclr\ilasm.exe' with /nologo "/out:"~PRIVATE~"\" ""~PRIVATE~"\AppData\Local\Temp\tmp5B69\"~PRIVATE~".il" /DLL "/resource="~PRIVATE~".res" /debug /PE64 /X64 /CVRES="C:\Windows\Microsoft.NET\Framework\v4.0.30319/" (TaskId:63) 1> ilasm '"~PRIVATE~"\packages\DllExport.1.5.1\tools\coreclr\ilasm.exe' returned gracefully. (TaskId:63) 1>"~PRIVATE~"\packages\DllExport.1.5.1\tools\net.r_eg.DllExport.targets(42,5): error : error : Failed to define security permission set for 0x20000001 1>"~PRIVATE~"\packages\DllExport.1.5.1\tools\net.r_eg.DllExport.targets(42,5): error : 1> at RGiesecke.DllExport.Parsing.IlParser.RunIlTool(String installPath, String toolFileName, String requiredPaths, String workingDirectory, String settingsName, String arguments, String toolLoggingCode, String verboseLoggingCode, IDllExportNotifier notifier, Int32 timeout, Func2 suppressErrorOutputLine) in D:\prg\projects\DllExport\DllExport\RGiesecke.DllExport\Parsing\IlParser.cs:line 378 1> at RGiesecke.DllExport.Parsing.IlAsm.RunCore(CpuPlatform cpu, String fileName, String ressourceParam, String ilSuffix) in D:\prg\projects\DllExport\DllExport\RGiesecke.DllExport\Parsing\ILAsm.cs:line 148 1> at RGiesecke.DllExport.Parsing.IlAsm.Run(String outputFile, String ilSuffix, CpuPlatform cpu) in D:\prg\projects\DllExport\DllExport\RGiesecke.DllExport\Parsing\ILAsm.cs:line 118 1> at RGiesecke.DllExport.Parsing.IlAsm.ReassembleFile(String outputFile, String ilSuffix, CpuPlatform cpu) in D:\prg\projects\DllExport\DllExport\RGiesecke.DllExport\Parsing\ILAsm.cs:line 80 1> at RGiesecke.DllExport.DllExportWeaver.reassembleFile(IlAsm ilAsm, String outputFile, String ilSuffix, CpuPlatform cpu) in D:\prg\projects\DllExport\DllExport\RGiesecke.DllExport\DllExportWeaver.cs:line 196 1> at RGiesecke.DllExport.DllExportWeaver.RunIlAsm(IlAsm ilAsm) in D:\prg\projects\DllExport\DllExport\RGiesecke.DllExport\DllExportWeaver.cs:line 147 1> at RGiesecke.DllExport.DllExportWeaver.Run() in D:\prg\projects\DllExport\DllExport\RGiesecke.DllExport\DllExportWeaver.cs:line 87 1> at RGiesecke.DllExport.MSBuild.ExportTaskImplementation1.Execute() in D:\prg\projects\DllExport\DllExport\RGiesecke.DllExport.MSBuild\RGiesecke.DllExport.MSBuild\ExportTaskImplementation.cs:line 437 (TaskId:63) 1>Done executing task "DllExportAppDomainIsolatedTask" -- FAILED. (TaskId:63) 1>Done building target "DllExportMod" in project "~PRIVATE~" -- FAILED.: (TargetId:101)

Example: [DllExport("about", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]

3F commented 7 years ago

Thanks for details !

Now it reproduced for me when I use the SecurityPermission.

error : Failed to define security permission set for ...

0x02000004

For something like this:

[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
internal class ClassA
{ }

your 0x20000001

For something like this:

[assembly: SecurityPermission(SecurityAction.RequestMinimum)] 

So, our bug from Assembler::EmitSecurityInfo

but mainly, the open ilasm on CoreCLR has a lot of restrictions :( like this, or this.