3F / DllExport

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

create a dll with reference to a nuget library #101

Closed fxl447098457 closed 5 years ago

fxl447098457 commented 5 years ago

here are the codes.i tried the dll in vba. class worked with the CreateIm method not available.error info:“QRCoder, Version=1.3.5.0, Culture=neutral, PublicKeyToken=null” or one of its dependencies. The system cannot find the file specified. could you give me some advice.many thx.

`using QRCoder; using System; using System.Drawing; using System.Runtime.InteropServices;

namespace Qrcode { [ComVisible(true), ClassInterface(ClassInterfaceType.AutoDual)] public class myqrcode { [return: MarshalAs(UnmanagedType.SysInt)] public int CreateIm([MarshalAs(UnmanagedType.BStr)]string s, [MarshalAs(UnmanagedType.BStr)]string filePath) { QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(s, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeImage = qrCode.GetGraphic(5, Color.Black, Color.White, null, 15, 6, false); qrCodeImage.Save(filePath); return 0; } } static class UnmanagedExports { [DllExport] [return: MarshalAs(UnmanagedType.IDispatch)] static Object CreateQrcodeClass() { return new myqrcode(); } } } `

3F commented 5 years ago

@fxl447098457 This is [ probably ] what you need: https://github.com/3F/DllExport/issues/86#issuecomment-429107792 Because I'm not sure what you're talking about at all. Does this have a bug or just a question.

Can you ask more clearly if it's not, sorry.

fxl447098457 commented 5 years ago

@3F just a question. it seems that 3rd dll does not work.should i use assembly to load the library just like #86?look forward to your reply.

3F commented 5 years ago

An assemblyResolve as one of the options. Follow my recommendations there with the user's example from last reply.

You need to try to use a common practice when debugging third-party libraries, look here: https://github.com/3F/DllExport/issues/84#issuecomment-417937869

fxl447098457 commented 5 years ago

sorry for my late feedback.assemblyreslove did work.