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

Does this project support third party DLL? #2015

Closed
HppZ opened this issue Nov 6, 2024 · 13 comments
Closed

Does this project support third party DLL? #2015

HppZ opened this issue Nov 6, 2024 · 13 comments

Comments

@HppZ
Copy link

HppZ commented Nov 6, 2024

No description provided.

@riverar
Copy link
Collaborator

riverar commented Nov 6, 2024

Not sure what that means, closing for now but feel free to add more detail!

@riverar riverar closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2024
@HppZ
Copy link
Author

HppZ commented Nov 7, 2024

I want to generate c# bindings for C dll automatically.

@riverar
Copy link
Collaborator

riverar commented Nov 7, 2024

@HppZ Check out my article on generating metadata here https://withinrafael.com/2023/01/18/generating-metadata-for-the-windows-crate/. You can then swap out windows-rs and Rust for CsWin32 and C#.

@HppZ
Copy link
Author

HppZ commented Nov 8, 2024

thank you!

how to customize DefaultDllImportSearchPaths, I want it to use DllImportSearchPath.ApplicationDirectory

[DllImport("testdll", ExactSpelling = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
internal static extern int add(int a, int b);

@riverar
Copy link
Collaborator

riverar commented Nov 8, 2024

Use an assembly attribute instead:

[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32)]

@HppZ
Copy link
Author

HppZ commented Nov 8, 2024

I want to change DllImportSearchPath.System32 to DllImportSearchPath.ApplicationDirectory in this generated code. The code is generated by cswin32 and can't be edited.

Image

@HppZ
Copy link
Author

HppZ commented Nov 8, 2024

I have to dig into source code of cswin32, but not resolved yet.

@HppZ
Copy link
Author

HppZ commented Nov 8, 2024

Use an assembly attribute instead:

[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32)]

I added AssemblyInfo.cs to project and this line [assembly: DefaultDllImportSearchPaths(DllImportSearchPath.ApplicationDirectory)] at the bottom of AssemblyInfo.cs, but not work.

@riverar
Copy link
Collaborator

riverar commented Nov 8, 2024

Ah, I didn't realize CsWin32 emits its own. @AArnott thoughts? Or should we file an issue over on CsWin32?

@HppZ
Copy link
Author

HppZ commented Nov 9, 2024

Ah, I didn't realize CsWin32 emits its own. @AArnott thoughts? Or should we file an issue over on CsWin32?

microsoft/CsWin32#1307

@HppZ
Copy link
Author

HppZ commented Nov 9, 2024

How to customize access level of generated code?

Image

@HppZ
Copy link
Author

HppZ commented Dec 13, 2024

any update?

@AArnott
Copy link
Member

AArnott commented Jan 25, 2025

@HppZ You can make these public by a setting in NativeMethods.json. The README file has details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants