Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to figure out why the symbol is not visible #224

Closed
viraptor opened this issue May 11, 2023 · 6 comments
Closed

How to figure out why the symbol is not visible #224

viraptor opened this issue May 11, 2023 · 6 comments
Labels

Comments

@viraptor
Copy link

I've got projects in VS 2022 which try to export a single function through:

        [DllExport("VirtualChannelEntry", CallingConvention.StdCall)]
        public static bool VirtualChannelEntry(ref ChannelEntryPoints entry)

(type in the signature from https://www.codeproject.com/Articles/16374/How-to-Write-a-Terminal-Services-Add-in-in-Pure-C)

I can load up and successfully build the example "DotNetCoreLibrary3" project and the function is exported as expected (checked with dumpbin /exports)

I compared the options I'm using to the example project and set exactly the same options in mine. (checked in the xml configs too)

I'm failing to see the exported symbol in my DLL though. I've tried new/clean core 6, standard 2 and framework 4.7 projects and none of them create the export. Tried with both debug and release builds. Each one goes through the configuration correctly and compiles successfully with the [DllExport...] attribute resolving and compiling.

How can I figure out what I'm missing here?

The question is related to:

  • DllExport -version: 1.7.4
  • Copy-paste from Data tab:
    core 6 project:
Installed: True; 1.7.4+c1cc52f; invoked: 1.7.4
Project type: Cs
Storage: TargetsFile
Compiler.Platform: Auto
Compiler.ordinalsBase: 1
Compiler.rSysObj: True
Compiler.ourILAsm: True
Compiler.customILAsm: 
Compiler.genExpLib: False
Compiler.peCheck: PeIl
Compiler.patches: InfToken
PreProc.Type: None
PreProc.Cmd: 
PostProc.Type: None
PostProc.ProcEnv: $(SolutionPath);$(MSBuildThisFileFullPath)
PostProc.Cmd: 
SignAssembly: 
Identifier: 02C832E4-47BB-4F37-8D40-B4653B9AB783
Instance: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe
Project path: C:\Users\vi\source\repos\StreamDeckTransport\StreamDeckTransportClientCs\StreamDeckTransportClientCs.csproj
Action: Configure
PlatformTarget: 
TargetFramework: net6.0
TargetFrameworks: 
TargetFrameworkVersion: 
RootNamespace: 
AssemblyName: 
MgrArgs: 
MetaLib: tools\raw\lib\net20\DllExport.dll
MetaCor: tools\raw\lib\netstd\DllExport.dll
Proxy: 
StoragePath: .net.dllexport.targets
ddNS: StreamDeckTransportClientCs
ddNS max buffer: 500
UseCecil: True
intermediateFiles: False
timeout: 30000
Options: None
RootPath: C:\Users\vi\source\repos\StreamDeckTransport\
PkgPath: C:\Users\vi\source\repos\StreamDeckTransport\packages\\DllExport.1.7.4\
SlnFile: 
SlnDir: C:\Users\vi\source\repos\StreamDeckTransport\
DxpTarget: tools\net.r_eg.DllExport.targets
MsgGuiLevel: -1
LockIfError: 

framework project:

Installed: True; 1.7.4+c1cc52f; invoked: 1.7.4
Project type: Cs
Storage: TargetsFile
Compiler.Platform: Auto
Compiler.ordinalsBase: 1
Compiler.rSysObj: True
Compiler.ourILAsm: True
Compiler.customILAsm: 
Compiler.genExpLib: False
Compiler.peCheck: PeIl
Compiler.patches: InfToken
PreProc.Type: None
PreProc.Cmd: 
PostProc.Type: None
PostProc.ProcEnv: $(SolutionPath);$(MSBuildThisFileFullPath)
PostProc.Cmd: 
SignAssembly: 
Identifier: A23570A4-FABA-4276-8A46-CD6C084CA478
Instance: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe
Project path: C:\Users\vi\source\repos\StreamDeckTransport\StreamDeckTransportClientCsFram\StreamDeckTransportClientCsFram.csproj
Action: Configure
PlatformTarget: 
TargetFramework: 
TargetFrameworks: 
TargetFrameworkVersion: v4.7.2
RootNamespace: StreamDeckTransportClientCsFram
AssemblyName: StreamDeckTransportClientCsFram
MgrArgs: 
MetaLib: tools\raw\lib\net20\DllExport.dll
MetaCor: tools\raw\lib\netstd\DllExport.dll
Proxy: 
StoragePath: .net.dllexport.targets
ddNS: StreamDeckTransportClientCsFram
ddNS max buffer: 500
UseCecil: True
intermediateFiles: False
timeout: 30000
Options: None
RootPath: C:\Users\vi\source\repos\StreamDeckTransport\
PkgPath: C:\Users\vi\source\repos\StreamDeckTransport\packages\\DllExport.1.7.4\
SlnFile: 
SlnDir: C:\Users\vi\source\repos\StreamDeckTransport\
DxpTarget: tools\net.r_eg.DllExport.targets
MsgGuiLevel: -1
LockIfError: 
@viraptor
Copy link
Author

Hope this helps: If I leave the intermediate objects, I see in Before:

  .method public hidebysig static bool  'VirtualChannelEntry'(valuetype 'Win32.WtsApi32'.'ChannelEntryPoints'& 'entry') cil managed
  {
    .custom instance void ['DllExport']'StreamDeckTransportClientCs'.'DllExportAttribute'::.ctor(string,
                                                                                                 valuetype ['System.Runtime.InteropServices']'System.Runtime.InteropServices'.'CallingConvention') = ( 01 00 13 56 69 72 74 75 61 6C 43 68 61 6E 6E 65   // ...VirtualChanne

And in after:

.method public hidebysig static bool modopt(['mscorlib']'System.Runtime.CompilerServices.CallConvStdcall')  'VirtualChannelEntry'(valuetype 'Win32.WtsApi32'.'ChannelEntryPoints'& 'entry')
  {
    .export [1] as 'VirtualChannelEntry'
    .maxstack  11

So it seems like the method was actually processed... But it's still not visible in the result.

@3F
Copy link
Owner

3F commented May 11, 2023 via email

@viraptor
Copy link
Author

🤦
Yes, the x64 directory does contain a file with the correct export.
Is there any way I can include that in the published directory as well? It seems that publishing to folder uses the library without the exports in place.

@3F
Copy link
Owner

3F commented May 14, 2023 via email

@viraptor
Copy link
Author

Awesome, thank you!

@3F 3F closed this as completed Sep 7, 2024
3F added a commit that referenced this issue Nov 24, 2024
Related issue #224
+`DllExportResolvePublish` to control it
@3F
Copy link
Owner

3F commented Nov 24, 2024

Starting with 2a8d962 DllExport will automatically resolve the Publish target for all types. You don't need to do anything else.

Optionally,

MSBuild Property / Environment variable Description
DllExportResolvePublish=false to disable resolving
DllExportResolvePublishForSingle=false to disable resolving for a single platform
DllExportFallbackDontCopyBuildOutputToPublishDirectory=false to disable fallback on DllExportResolvePublishForSingle

3F added a commit that referenced this issue Feb 25, 2025
* NEW: Extends support for .NET 9, .NET 8, .NET 7,
       .NET 6, .NET 5, netcoreapp3.1, netstandard2.1, ...
       Issues: #219, #193, #132, #239

* NEW: Custom `.typref ...` & `.assembly extern ...` in the Wizard
       using modern 3F's IL Assembler 9.3+

* NEW: Support $-interpolation in modern .NET 9-6, Span, Memory, ...
       configure in the Wizard.

* NEW: New [Ref] packages control and related options.

* NEW: ImageBase + step control in multiple targeting.
       configure in the Wizard.

* NEW: New `DllExport -pe` keys:
          -list-addr, -list-ord, -list-all
          -magic, -num-functions, -base

* NEW: Official ILRepack support in Pre-processing; 2.0.39
       https://github.com/gluck/il-repack/releases/tag/2.0.39

* NEW: New PE Check option to control PE32/PE32+ arch.

* NEW: -action RecoverInit in addition to -action Recover;
       Recover to initial setup using predefined/exported data.

* NEW: Option to refresh intermediate module (obj) using modified. Issue #206.

* NEW: x86+x64 copy support for `Publish` targets. Related issue #224.
       `DllExportResolvePublish` property to control it.

* FIXED: Crashes or empty exports if code contains `.class extern forwarder` declarations.

* FIXED: error: syntax error at token '.' in .interfaceimpl type... Issue: #205.

* FIXED: Post-Proc: possible "The given key was not present in the dictionary."

* FIXED: Fixed Pre-Proc ILMerge for netcore.

* FIXED: Fix copying to own directory for "Provide x86+x64 assemblies"
         when no active dependencies.

* FIXED: Pre-Proc: fixed edit Exec raw command in the Wizard.

* FIXED: Fixed possible Incorrect RVA: 0 when PE Check is on.

* FIXED: Fixed -action Export: Parameter "unevaluatedValue" cannot be null.

* FIXED: Fixed Post-Proc DllExportDirX64 & DllExportDirX86 properties.

* FIXED: DllExportResolvePublish support for a single platform
         Related issue #235 or like.

* FIXED: Failed to write to log file ... because it is being used by another process. Issue #223.

* CHANGED: Execute `-action Restore` in case of loss of generated meta
         for the cases like ImplicitUsings=true etc.
         It will probably help with problems like #184.

* CHANGED: Improved support for nested projects using $(DllExportDir) etc.

* CHANGED: Improved managing `PlatformTarget` when applying the configuration.

* CHANGED: Improved TargetFrameworks multi-targeting support. ImageBase can be configured separately.

* CHANGED: Improved IsNetCoreBased logic for modern tfms.

* CHANGED: Improved cleaning logic at Pre-processing stage to delete correctly DllExport.Dll, Conari.dll
           and other assemblies from TargetDir when merging using [Ref] etc.

* CHANGED: `DllExport -action keys` are no longer case sensitive.

* CHANGED: Adds /PDB /OPTIMIZE and other types of PDB generation.
            Automatic option is relied on DebugType + Optimize + DebugSymbols properties:
            * Optimize: Optimize long instructions to short
            * PdbOptimize: +Create the PDB file without enabling debug info tracking
            * DebugOptimize: Enable JIT optimization, create PDB file, use implicit sequence points
            * Debug: Disable JIT optimization, create PDB file, use sequence points from PDB
            * DebugImpl: Disable JIT optimization, create PDB file, use implicit sequence points
            * Legacy True/False: Debug or Optimize

* CHANGED: Updated .PDB deletion logic according to ISymUnmanagedWriter problem.

* CHANGED: Use `wDxpMsgLevel` environment variable to control message level.

* CHANGED: Full integration with modern hMSBuild 2.4.1+
           https://github.com/3F/hMSBuild
           ```
           DllExport -hMSBuild -help
           ```

           GetNuTool now through hMSBuild engine:
           ```
           DllExport -hMSBuild -GetNuTool ...
           ```

* CHANGED: `DllExport -pe-exp-list` marked as obsolete;
           Use new `-pe` instead.
           ```
           DllExport -pe -help
           ```

* CHANGED: +Log option for IlMerge & ILRepack in the Wizard.

* CHANGED: Changed `-action Upgrade` logic same to `-action Configure`

* CHANGED: Make all paths relative as `$(DllExportDir)..\` in configured project files.

* CHANGED: Updated wrapper in offline version
           `offline.DllExport.1.8...zip` https://www.nuget.org/packages/DllExport/1.8

* CHANGED: Added netfx4sdk 1.2 helper to build using legacy tfm
           https://github.com/3F/netfx4sdk

* CHANGED: Updated
           * ILAsm 9.3.0
             https://github.com/3F/coreclr/releases/tag/9.3.0

           * ILMerge 3.0.41
             https://www.nuget.org/packages/ilmerge/3.0.41

           * Cecil 0.11.6
             https://github.com/jbevain/cecil/releases/tag/0.11.6

           * Conari 1.5.0
             https://github.com/3F/Conari/releases/tag/1.5

           * MvsSln 2.7 with enabled Huid implementation
             3F/MvsSln#51 (comment)

* NOTE: Tests for net9.0;net8.0;net7.0;net6.0;net5.0;netcoreapp3.1;netstandard2.1;netstandard2.0;net472;...
        can be found in official repo https://github.com/3F/DllExport

        ~ https://github.com/3F/DllExport/tree/master/src/DllExport/assets
          https://github.com/3F/DllExport/tree/master/src/DllExport/UnitedTest

* NOTE: To upgrade to 1.8:
        DllExport -mgr-up -dxp-version 1.8
        or
        DllExport -action Upgrade -dxp-version 1.8

* NOTE: official manager can be found here:
        https://3F.github.io/DllExport/releases/latest/manager/
        or here:
        * https://github.com/3F/DllExport/releases/tag/1.8
        * https://www.nuget.org/packages/DllExport/1.8
3F added a commit that referenced this issue Feb 25, 2025
* NEW: Extends support for .NET 9, .NET 8, .NET 7,
       .NET 6, .NET 5, netcoreapp3.1, netstandard2.1, ...
       Issues: #219, #193, #132, #239

* NEW: Custom `.typref ...` & `.assembly extern ...` in the Wizard
       using modern 3F's IL Assembler 9.3+

* NEW: Support $-interpolation in modern .NET 9-6, Span, Memory, ...
       configure in the Wizard.

* NEW: New [Ref] packages control and related options.

* NEW: ImageBase + step control in multiple targeting.
       configure in the Wizard.

* NEW: New `DllExport -pe` keys:
          -list-addr, -list-ord, -list-all
          -magic, -num-functions, -base

* NEW: Official ILRepack support in Pre-processing; 2.0.39
       https://github.com/gluck/il-repack/releases/tag/2.0.39

* NEW: New PE Check option to control PE32/PE32+ arch.

* NEW: -action RecoverInit in addition to -action Recover;
       Recover to initial setup using predefined/exported data.

* NEW: Option to refresh intermediate module (obj) using modified. Issue #206.

* NEW: x86+x64 copy support for `Publish` targets. Related issue #224.
       `DllExportResolvePublish` property to control it.

* FIXED: Crashes or empty exports if code contains `.class extern forwarder` declarations.

* FIXED: error: syntax error at token '.' in .interfaceimpl type... Issue: #205.

* FIXED: Post-Proc: possible "The given key was not present in the dictionary."

* FIXED: Fixed Pre-Proc ILMerge for netcore.

* FIXED: Fix copying to own directory for "Provide x86+x64 assemblies"
         when no active dependencies.

* FIXED: Pre-Proc: fixed edit Exec raw command in the Wizard.

* FIXED: Fixed possible Incorrect RVA: 0 when PE Check is on.

* FIXED: Fixed -action Export: Parameter "unevaluatedValue" cannot be null.

* FIXED: Fixed Post-Proc DllExportDirX64 & DllExportDirX86 properties.

* FIXED: DllExportResolvePublish support for a single platform
         Related issue #235 or like.

* FIXED: Failed to write to log file ... because it is being used by another process. Issue #223.

* CHANGED: Execute `-action Restore` in case of loss of generated meta
         for the cases like ImplicitUsings=true etc.
         It will probably help with problems like #184.

* CHANGED: Improved support for nested projects using $(DllExportDir) etc.

* CHANGED: Improved managing `PlatformTarget` when applying the configuration.

* CHANGED: Improved TargetFrameworks multi-targeting support. ImageBase can be configured separately.

* CHANGED: Improved IsNetCoreBased logic for modern tfms.

* CHANGED: Improved cleaning logic at Pre-processing stage to delete correctly DllExport.Dll, Conari.dll
           and other assemblies from TargetDir when merging using [Ref] etc.

* CHANGED: `DllExport -action keys` are no longer case sensitive.

* CHANGED: Adds /PDB /OPTIMIZE and other types of PDB generation.
            Automatic option is relied on DebugType + Optimize + DebugSymbols properties:
            * Optimize: Optimize long instructions to short
            * PdbOptimize: +Create the PDB file without enabling debug info tracking
            * DebugOptimize: Enable JIT optimization, create PDB file, use implicit sequence points
            * Debug: Disable JIT optimization, create PDB file, use sequence points from PDB
            * DebugImpl: Disable JIT optimization, create PDB file, use implicit sequence points
            * Legacy True/False: Debug or Optimize

* CHANGED: Updated .PDB deletion logic according to ISymUnmanagedWriter problem.

* CHANGED: Use `wDxpMsgLevel` environment variable to control message level.

* CHANGED: Full integration with modern hMSBuild 2.4.1+
           https://github.com/3F/hMSBuild
           ```
           DllExport -hMSBuild -help
           ```

           GetNuTool now through hMSBuild engine:
           ```
           DllExport -hMSBuild -GetNuTool ...
           ```

* CHANGED: `DllExport -pe-exp-list` marked as obsolete;
           Use new `-pe` instead.
           ```
           DllExport -pe -help
           ```

* CHANGED: +Log option for IlMerge & ILRepack in the Wizard.

* CHANGED: Changed `-action Upgrade` logic same to `-action Configure`

* CHANGED: Make all paths relative as `$(DllExportDir)..\` in configured project files.

* CHANGED: Updated wrapper in offline version
           `offline.DllExport.1.8...zip` https://www.nuget.org/packages/DllExport/1.8

* CHANGED: Added netfx4sdk 1.2 helper to build using legacy tfm
           https://github.com/3F/netfx4sdk

* CHANGED: Updated
           * ILAsm 9.3.0
             https://github.com/3F/coreclr/releases/tag/9.3.0

           * ILMerge 3.0.41
             https://www.nuget.org/packages/ilmerge/3.0.41

           * Cecil 0.11.6
             https://github.com/jbevain/cecil/releases/tag/0.11.6

           * Conari 1.5.0
             https://github.com/3F/Conari/releases/tag/1.5

           * MvsSln 2.7 with enabled Huid implementation
             3F/MvsSln#51 (comment)

* NOTE: Tests for net9.0;net8.0;net7.0;net6.0;net5.0;netcoreapp3.1;netstandard2.1;netstandard2.0;net472;...
        can be found in official repo https://github.com/3F/DllExport

        ~ https://github.com/3F/DllExport/tree/master/src/DllExport/assets
          https://github.com/3F/DllExport/tree/master/src/DllExport/UnitedTest

* NOTE: To upgrade to 1.8:
        DllExport -mgr-up -dxp-version 1.8
        or
        DllExport -action Upgrade -dxp-version 1.8

* NOTE: official manager can be found here:
        https://3F.github.io/DllExport/releases/latest/manager/
        or here:
        * https://github.com/3F/DllExport/releases/tag/1.8
        * https://www.nuget.org/packages/DllExport/1.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants