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

Build successful but methods are not exported #59

Closed
bbartels opened this issue Nov 29, 2017 · 12 comments
Closed

Build successful but methods are not exported #59

bbartels opened this issue Nov 29, 2017 · 12 comments
Milestone

Comments

@bbartels
Copy link

bbartels commented Nov 29, 2017

How to reproduce

Open Solution in VS and build.

Build is successful and build log indicates that the Exported methods are assembled correctly, though when using dumpbin they do not show up.

Code repository: https://github.com/bbartels/K8055Simulator/tree/DLLExportIssues

What version and selected configuration ?

DLLExport.1.5.2

Can you provide detailed log of your build ?

https://pastebin.com/gUBpwPVv

I am in the middle of porting my project from R.Giesecke's UnmanagedExports to DLLExport.1.5.2, didn't have an issue with UnmanagedExports. (Except not being able to find ILdasm at times, which is the reason why I am porting)

@3F
Copy link
Owner

3F commented Nov 29, 2017 via email

@Genteure
Copy link
Contributor

From the log, it seems some methods got successful exported.
Which reminds me of about a month ago, I had a similar problem.

I have a project that has two source file contains methods need to export.
One of them successful export every time I build, the other one doesn't get exported every time.
I checked build result using dnSpy, the DllExport Attribute didn't get removed.

I was able to find a kind simple solution: just change the order of Compile ItemGroup in the csproj file so the compiler compiles source files in a different order. which somehow magically solved the problem.

Not sure if is the same problem, but you can give a try.

@3F
Copy link
Owner

3F commented Nov 29, 2017

1.6-RC also provides PE-checking via $(DllExportPeCheck) - #55 (comment)

  • 0x01 bit - Will check count of all planned exports from final PE32/PE32+ module.
  • 0x02 bit - Will check existence of all planned exports (IL code) in actual PE32/PE32+ module.

just change the order of Compile ItemGroup in the csproj file so the compiler compiles source files in a different order.

@Genteure can you try to reproduce this problem for RC + our IL Asm ? I will look into later if it still...

@bbartels
Copy link
Author

@3F I have tried the 1.6 Beta but haven't tried the RC yet. Will do so as soon as I can.

@Genteure
Copy link
Contributor

@3F You can check out my repository, I pushed 3 new branches with build log and result binary.

dllexport-16b2

Current working example, everything works fine.

dllexport-16b2-bug

Default build order, methods in Main.cs doesn't get exported.

dllexport-16rc

Default build order with DllExport 1.6.0-RC, methods in Main.cs doesn't get exported.

DllExport Configure
Build Result

@3F
Copy link
Owner

3F commented Nov 30, 2017

@Genteure Thanks for the detailed info ! I will look this as soon as possible.

By the way, what your system locale ? it seems you have incorrect layout :( a little bit, but...

@Genteure
Copy link
Contributor

My system locale is zh_CN Simplified Chinese, on Windows 10.
I changed my Visual Studio's language to English so msbuild log is in English.

@3F
Copy link
Owner

3F commented Nov 30, 2017

@Genteure Good, I'll try your locale in VM :)

Wizard here if you want to help: https://github.com/3F/DllExport/tree/master/Wizard

@3F
Copy link
Owner

3F commented Dec 2, 2017

@Genteure

well, yes 1.6-RC indicates 2 errors when PE-checking is used (your branch dllexport-16rc):

RunIlAsm: Something went wrong. We can't find '2' exports from PE32/PE32+ module '\com.genteure.cqp.whatanime\bin\Debug\com.genteure.cqp.whatanime.dll': _eventEnable ; _eventGroupMsg	com.genteure.cqp.whatanime	\packages\DllExport.1.6.0-RC\tools\net.r_eg.DllExport.targets		
RunIlAsm: The number (2) of exports from PE32/PE32+ module '\com.genteure.cqp.whatanime\bin\Debug\com.genteure.cqp.whatanime.dll' is not equal to number (4) from IL code.	com.genteure.cqp.whatanime	\packages\DllExport.1.6.0-RC\tools\net.r_eg.DllExport.targets		

And I've found the following problem from your code. The problem mainly because of another decompiled view of extern methods (where DllImport attr) from your NativeMethods static class:

  .class abstract auto ansi sealed nested private beforefieldinit 'NativeMethods'
         extends ['mscorlib']'System'.'Object'
  {
    ...
    .method public hidebysig static pinvokeimpl("CQP.DLL" winapi) 
            string  'CQ_getRecord'(int32 'AuthCode',
                                   string 'File',
                                   string 'Format') cil managed preservesig
    {
    }
    ...

In general, we have incorrect nesting level of subclasses because of our current logic via stack-based levels.

Well, need to think...

While I'm thinking, you can also try https://github.com/3F/Conari that generates binding at runtime, and moreover...

@3F
Copy link
Owner

3F commented Dec 2, 2017

@bbartels I've also checked your bbartels/K8055Simulator@2cbbe82 and for v1.6-RC I have no problems:

x64:

00000001	0003EB9E	0000	0004022A	OpenDevice
00000002	0003EBAA	0001	0004021E	CloseDevice
00000003	0003EBB6	0002	00040276	ReadAnalogChannel
00000004	0003EBC2	0003	00040259	ReadAllAnalog
00000005	0003EBCE	0004	000401F7	ClearAnalogChannel
00000006	0003EBDA	0005	000401D8	ClearAllAnalog
00000007	0003EBE6	0006	00040245	OutputAnalogChannel
00000008	0003EBF2	0007	00040235	OutputAllAnalog
00000009	0003EBFE	0008	00040300	SetAnalogChannel
0000000A	0003EC0A	0009	000402E5	SetAllAnalog
0000000B	0003EC16	000A	000401E7	ClearAllDigital
0000000C	0003EC22	000B	0004020A	ClearDigitalChannel
0000000D	0003EC2E	000C	000402F2	SetAllDigital
0000000E	0003EC3A	000D	0004033E	SetDigitalChannel
0000000F	0003EC46	000E	00040367	WriteAllDigital
00000010	0003EC52	000F	000402AC	ReadDigitalChannel
00000011	0003EC5E	0010	00040267	ReadAllDigital
00000012	0003EC6A	0011	000402A0	ReadCounter
00000013	0003EC76	0012	000402D8	ResetCounter
00000014	0003EC82	0013	00040327	SetCounterDebounceTime
00000015	0003EC8E	0014	00040350	SetDigitalInputChannel
00000016	0003EC9A	0015	000402BF	ReadDigitalOutputChannel
00000017	0003ECA6	0016	00040311	SetAnalogInputChannel
00000018	0003ECB2	0017	00040288	ReadAnalogOutputChannel

@3F
Copy link
Owner

3F commented Dec 15, 2017

Ok, I've plan to view this problem later, after planned v1.6 (should be released for this month).

For today, anyone else may also try to use https://github.com/3F/Conari to avoid similar @Genteure's problem.

@3F 3F added this to the v1.6.1 milestone Dec 15, 2017
3F added a commit that referenced this issue Dec 29, 2017
* NEW: The new embeddable lightweight manager for distribution via MvsSln & GetNuTool projects. Issue #38.
       Based on hMSBuild logic and includes GetNuTool core v1.6.1.

       Now you shouldn't use standard nuget clients anymore:
       https://www.youtube.com/watch?v=9bYgywZ9pPE

       Quick start: https://www.youtube.com/watch?v=sBWt-KdQtoc
        ==============================
        DllExport -action Configure
        ==============================

       Package from nuget.org already contains manager, but you can also get it directly.
       Latest manager: https://3F.github.io/DllExport/releases/latest/manager/
       ~18 Kb text-based embeddable batch-script that does not require powershell and dotnet-cli.

       Automatic restoring still is available but you can also use: `DllExport -action Restore`
       All available features: `DllExport -h`

       Direct links to remote package (without nuget server) via `-pkg-link {uri}` key. Issue #53.
       NuGet Server by default: nuget.org.

* NEW: The new Wizard (configurator via MvsSln). To easy configure your projects in any place. Part of Issue #38.
       MvsSln v2.0: https://github.com/3F/MvsSln

* NEW: Added support of empty/global namespaces - Issue #47.
       Use `Direct-Mod` if Cecil will not process this correctly.

* NEW: Implemented another storage for configuration: '.net.dllexport.targets'. Issue #49.

* NEW: New settings for configurator (Wizard):
        * Path to custom ILAsm.
        * Flag to keep intermediate Files (IL Code, Resources, ...).
        * Timeout of execution in milliseconds.

* NEW: Implemented automatic checking existence of a correct exported proc via Conari. Issue #55.
       Wizard controls it via `$(DllExportPeCheck)`:
        * 0x01 bit - Will check count of all planned exports from final PE32/PE32+ module.
        * 0x02 bit - Will check existence of all planned exports (IL code) in actual PE32/PE32+ module.

* NEW: Implemented PE32/PE32+ Viewer to check manually available exports from final modules. Issue #55.
       New key for manager:
        ```
        -pe-exp-list {module} - To list all available exports from PE32/PE32+ module.
        ```

        Sample:
        ```
        DllExport -pe-exp-list bin\Debug\regXwild.dll
        ```

* FIXED: Fixed target platform detection. Issue #34.
         Details: #34 (comment)

* FIXED: Fixed problem when the Post-Build event is triggered before our tool. Issue #35.
         Use this if still is needed:
         ```
         <Target Name="PostBuildEventBeforeDllExport" BeforeTargets="DllExportMod">
            ...
         </Target>
         ```

* FIXED: Fixed generation of exp + .lib via MS Library Manager for VS2017. Issue #37.
         Now it also includes processing through VsDevCmd & VcVarsAll initializer scripts.
         Use the folowing msbuild properties to override values by default:
         * $(DllExportVcVarsAll); $(DllExportVsDevCmd)

* FIXED: Fixes possible problem with multiple properties that contains *Undefined* word,
         e.g.: *Undefined*\path1;C:\path2 ...

* CHANGED: Added information about finding lib tool. Issue #44.

* CHANGED: UI. Selected platform now affects to all configurations of project instead of active as before.

* CHANGED: Now nuget package does not contain library in `lib/.../` Details in #36.

* CHANGED: Now we also distribute .zip package for work through our manager etc.
           https://github.com/3F/DllExport/releases

* NOTE: How to avoid EXP0014: RunIlAsm. The library manager still cannot be found.
        https://www.youtube.com/watch?v=zUejJ4vUPGw
        Related Issue #44

* NOTE: Quick start (Configuring, Automatic restoring, Pe-Viewer):
        https://www.youtube.com/watch?v=sBWt-KdQtoc

* NOTE: The latest text-based manager:
        https://3F.github.io/DllExport/releases/latest/manager/

           Other versions you can find from GitHub Releases:
           * https://github.com/3F/DllExport/releases

           Or get it from nuget packages starting with v1.6+

* NOTE: PE-features via Conari v1.3.0 https://github.com/3F/Conari

* KNOWN: Bug when - "Build successful but methods are not exported." Issue #59
         For today, anyone else may also try to use https://github.com/3F/Conari to avoid similar @Genteure's problem.

* DIFF(v1.6-RC):

    * FIXED: Wizard. Fixed incorrect layout for zh_CN Simplified Chinese (Thanks @Genteure). Issue #61
    * FIXED: Fixes automatic restoring the package via msbuild. Issue #62
@3F
Copy link
Owner

3F commented Aug 2, 2018

Fixed and included in planned v1.6.1

Use CI-Build-92 for tests.

@3F 3F closed this as completed Aug 2, 2018
3F added a commit that referenced this issue Aug 5, 2018
* FIXED: Fixed bug when some methods cannot be exported. Issue #59.
* FIXED: Bug 'The node is not parented by this object' when Configuring projects. Issue: #77.
* FIXED: Fixed GDI objects leak in Wizard.
* FIXED: `-msb` key cannot affect for GetNuTool section. Issue #74.
* FIXED: Bug when automatic restoring still uses default keys from manager after configuring with custom `-server`.
* FIXED: Problem with double quotes for `-packages` key.
* FIXED: Possible incorrect repetition of the relative path for `-packages` key.
* FIXED: Possible problem 'The request was aborted: Could not create SSL/TLS secure channel.'. Issue: #77.
* FIXED: Possible problem with path when `-msb` key contains round brackets,
         e.g.: `D:\C\Program Files (x86)\Microsoft Visual Studio\`...

* NEW: Implemented features for additional automation. Issue #76.
        New actions:
            * `-action Export`
            * `-action Recover`
            * `-action Unset`

        Documentation: https://github.com/3F/DllExport/wiki/DllExport-Manager#automation

* NEW: Added proxy support for manager.
        The common format: `[usr[:pwd]@]host[:port]`

        Documentation: https://github.com/3F/DllExport/wiki/DllExport-Manager#proxy

* NEW: Wizard. Added sorting an projects in main window by its installing status and by availability.
* NEW: Wizard. Added filter for list of projects in main wizard window.
* NEW: New 'Offline' versions from our packages. See GitHub Releases page.
* NEW: Added key to force update `Reference` without PublicKeyToken. Issue #65.
* NEW: Added `-force` key for manager to use aggressive behavior, e.g. like removing pkg when updating.
       Wiki: https://github.com/3F/DllExport/wiki/DllExport-Manager#receiving-new-package-version

* NEW: New action `-action Upgrade`.
       Aggregates an Update action with additions for upgrading.

            Today's an Upgrade action:
            ```
            DllExport -action Upgrade ...
            ```

            is equal to:
            ```
            DllExport -action Update -mgr-up -force ...
            ```

            Wiki: https://github.com/3F/DllExport/wiki/DllExport-Manager#updating

* CHANGED: Case sensitivity for the Action names.
* CHANGED: `-action Default` for nothing.
* CHANGED: UI layout fixes for -Info form (Thanks @Genteure, Issue #61).
* CHANGED: Allows absolute path for `-packages` key.
* CHANGED: `-sln-file` key now can affect to `-action Configure`
* CHANGED: hMSBuild tool now is also distributed inside root directory of the packages zip & nupkg.
           Use this for EXP0014 problem: "RunIlAsm. The library manager still cannot be found."
           Example: https://www.youtube.com/watch?v=zUejJ4vUPGw

* CHANGED: Updated GetNuTool v1.6.2
* CHANGED: Updated MvsSln v2.1.0
* OTHER: Some other fixes and changes with manager and wizard.
* NOTE: To upgrade configured version: `DllExport -action Upgrade ...`
* NOTE: Configuring projects: `DllExport -action Configure ...`
* NOTE: Screencasts:
            * Quick start: https://www.youtube.com/watch?v=sBWt-KdQtoc
            * Basic examples for C++ and C#: https://www.youtube.com/watch?v=9Hyg3_WE9Ks
            * Complex types and Strings: https://www.youtube.com/watch?v=QXMj9-8XJnY

* NOTE: Our actual wiki - https://github.com/3F/DllExport/wiki
        * Documentation for manager: https://github.com/3F/DllExport/wiki/DllExport-Manager
@3F 3F mentioned this issue Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants