# Dll by cmake with DllExport does not work in another application

**URL:** https://discourse.cmake.org/t/dll-by-cmake-with-dllexport-does-not-work-in-another-application/2879
**Category:** Usage
**Tags:** os:windows
**Created:** [March 3, 2021, 9:25am UTC](https://discourse.cmake.org/t/dll-by-cmake-with-dllexport-does-not-work-in-another-application/2879 "2021-03-03T09:25:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Bogdan029](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bogdan029/32/1260_2.png) [@Bogdan029](https://discourse.cmake.org/u/Bogdan029)
#### Post date: [March 3, 2021, 9:25am UTC](https://discourse.cmake.org/t/dll-by-cmake-with-dllexport-does-not-work-in-another-application/2879/1 "2021-03-03T09:25:38Z")

</div>

I want to create dll of my c# project with DllExport by cmake for use in another app(java), but I collided wit problem, app with the dll that I created by VS2019, works Ok, but with the dll that was created by cmake (using commands: “cmake . -B build/ -A x64” and "cmake --build build/) does not work (just crash). Could anybody help me?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 3, 2021, 6:01pm UTC](https://discourse.cmake.org/t/dll-by-cmake-with-dllexport-does-not-work-in-another-application/2879/2 "2021-03-03T18:01:10Z")

</div>

Do you have a backtrace or any more information about the crash?

---

<div class="post-metadata">

### Author: ![Bogdan029](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bogdan029/32/1260_2.png) [@Bogdan029](https://discourse.cmake.org/u/Bogdan029)
#### Post date: [March 3, 2021, 8:01pm UTC](https://discourse.cmake.org/t/dll-by-cmake-with-dllexport-does-not-work-in-another-application/2879/3 "2021-03-03T20:01:44Z")

</div>

Probably I should add something in my CMakeList file, that applies to DllExport library.  
Because I can’t see any of functions of my dll, created by cmake, using tool CFF Explorer  
my CMakeList.txt :

```
# Setup project.
PROJECT(C++.Wrapper VERSION 1.0.0.0 LANGUAGES CSharp)

# Setup project to use C# utilities.
INCLUDE(CSharpUtilities)

# Create assembly info with current version.
CONFIGURE_FILE("Properties/AssemblyInfo.cs" "Properties/AssemblyInfo.cs")

# Add shared library project.
ADD_LIBRARY(${PROJECT_NAME} SHARED
    "../BLE.API/Core/BleApi.cs"
    "../BLE.API/Interfaces/IBleApi.cs"
    "../BLE.API/Interfaces/IDeviceInfoApi.cs"
    "../BLE.API/Interfaces/IIlluminationApi.cs"
    "../BLE.API/Interfaces/IMeasurements.cs"
    "../Plugin.BLE/Core/AttributeType.cs"
    "../Plugin.BLE/Core/BluetoothLE.cs"
    "../Plugin.BLE/Core/BluetoothLEAttributeDisplay.cs"
    "../Plugin.BLE/Core/BluetoothLEDeviceDisplay.cs"
    "../Plugin.BLE/Core/DataFormat.cs"
    "../Plugin.BLE/Core/DeviceWatcherHelper.cs"
    "../Plugin.BLE/Core/EnumGuidMapperAttribute.cs"
    "../Plugin.BLE/Core/GattNativeCharacteristicUuid.cs"
    "../Plugin.BLE/Core/GattNativeDescriptorUuid.cs"
    "../Plugin.BLE/Core/GattNativeServiceUuid.cs"
    "../Plugin.BLE/Core/TaskExtensions.cs"
    "../Plugin.BLE/Core/Utilities.cs"
    "../Plugin.BLE/Enums/CustomCharacteristics.cs"
    "../Plugin.BLE/Enums/CustomServices.cs"
    "../Plugin.BLE/Interfaces/IBluetoothLE.cs"
    "../Plugin.BLE/Interfaces/IDeviceInfo.cs"
    "../Plugin.BLE/Interfaces/IIllumination.cs"
    "../Plugin.BLE/Interfaces/IMeasurements.cs"
	"BleApiWrapper.cs"
)
include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME})

 set_property(TARGET ${PROJECT_NAME}
     PROPERTY VS_PACKAGE_REFERENCES "Microsoft.Windows.SDK.Contracts_10.0.19041.1" )
	 
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCE_Windows
    ${CMAKE_INSTALL_EXPORT_DIR}Windows.winmd)
	
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCE_DllExport
    ${CMAKE_INSTALL_EXPORT_DIR}DllExport.1.7.4/gcache/metalib/C__.Wrapper/DllExport.dll)
	
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCE_System.Runtime.WindowsRuntime
    ${CMAKE_INSTALL_EXPORT_DIR}system.runtime.windowsruntime/4.6.0/lib/netstandard2.0/System.Runtime.WindowsRuntime.dll)
	
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCE_System.Runtime.WindowsRuntime.UI.Xaml
    ${CMAKE_INSTALL_EXPORT_DIR}system.runtime.windowsruntime.ui.xaml/4.6.0/lib/netstandard2.0/System.Runtime.WindowsRuntime.UI.Xaml.dll)

# Define dependencies.
TARGET_LINK_LIBRARIES(${PROJECT_NAME} 
    PUBLIC CommonLib
)

# Set CLR assembly properties.
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
    VS_DOTNET_REFERENCES "System;System.IO;System.Threading;"
    VS_GLOBAL_ROOTNAMESPACE ${PROJECT_NAME}
)

# Setup installer.
INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINARY_DIR}
    INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR}
)

# Export config.
INSTALL(EXPORT ${PROJECT_NAME}Config DESTINATION ${CMAKE_INSTALL_EXPORT_DIR})
EXPORT(TARGETS ${PROJECT_NAME} FILE ${PROJECT_NAME}Config.cmake)
```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 4, 2021, 1:48pm UTC](https://discourse.cmake.org/t/dll-by-cmake-with-dllexport-does-not-work-in-another-application/2879/4 "2021-03-04T13:48:55Z")

</div>

Hmm. I’m afraid I’m already out of my depths with my C# knowledge.
